I'm wondering, I've been using Netbeans as a learning tool for java and for the past programs that I've made I've been using:
this.dispose();
Frame2 frame2 = new frame2();
frame2.setVisible(true);
Is this the best way to do it?
I'm wondering, I've been using Netbeans as a learning tool for java and for the past programs that I've made I've been using:
this.dispose();
Frame2 frame2 = new frame2();
frame2.setVisible(true);
Is this the best way to do it?
It looks like you're trying to swap JFrames. If so, the best thing to do is to change your GUI structure to avoid doing this as window swapping can be rather annoying to the user and is usually unnecessary. Rather than swapping full fledged windows, better to have one main GUI window, one JFrame, and swap views which are often JPanels. The CardLayout can help you do this. This is yet another reason most Swing GUI programs should be geared towards creation of JPanels and not JFrames or JApplets. Doing this will greatly increase the flexibility and potential power of your code.
The tutorial can be found here: CardLayout tutorial.