Java: Get Mainform object from JInternalFrame

Posted by rodion on Stack Overflow See other posts from Stack Overflow or by rodion
Published on 2010-03-21T06:19:06Z Indexed on 2010/03/21 6:21 UTC
Read the original article Hit count: 374

Filed under:

Can I do this without reference to the object in the constructor? In other words, any class inherited from FrmTaoChild when creating must to add the button on the toolbar of the main window

public class FrmTaoMain extends JFrame {
  JToolBar tbTask = new JToolBar();
  public FrmTaoMain(String Caption) {
     super(Caption);
     ... 
     FrmTaoChild FrmChild = new FrmTaoChild(tbTask,"test");

  }
}   

public class FrmTaoChild extends JInternalFrame {
  public FrmTaoChild(JToolBar tbTask, String Caption)
  {
    super (Caption);
    JButton btnTask = new JButton(Caption);
    tbTask.add(btnTask);
  }
}

© Stack Overflow or respective owner

Related posts about java