Reputation: 33
I made a project in Java (Netbeans). I have a lot of frames, and when i want to change frame, i use this code:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dispose();
Opt p_b = new Opt();
p_b.setVisible(true);
}
But, i do not want to see when a frame closes and one other opens. I want to open all frames, in the same window. Do you understand me or did I not describe well? Can you help me? Or give me an example?
Upvotes: 1
Views: 3247
Reputation: 1
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setVisible(true);
dispose();
Opt p_b = new Opt();
p_b.setVisible(true);
}
Have the setVisible(true);
at the beginning of your code, so every window will remain open.
Upvotes: 0
Reputation: 167
use one JFrame that has multiple JPanels; and switch between JPanels (using CardLayout).
check Oracle link it has a lot of examples about layouts managers
Upvotes: 1