You can have one contain another and have the one being contained set to false, visibilty, then change the visibility. Something like this
public class AFrame extends JFrame {
private JButton jbt = new JButton("Open Window");
private BFrame jfrm = new BFrame();
public class AFrame(){
add(jbt);
jfrm.setVisibile(false);
add(jfrm);
jbt.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
jfrm.setVisibile(true);
}
});
}
}
public class BFrame extends JFrame {
public BFrame(){
}
}
When "Open Window" button is pressed, the BFrame
is set to visible, then appears. The AFrame
is the starting program, which contains a BFrame