I'm a beginner in Java, coming from VB.net. Here's what I'm trying to do using Netbeans:
I've created 2 JFrame
classes: JFrame1 and JFrame2.
The first one is instantiated from the main class of the project.
There is a button on JFrame1. When I click it, a new instance of JFrame2 is created and shown, and the already created instance of JFrame1 is hidden. With another button on the JFrame2, how do I make the already created JFrame1 visible again without creating a new instance. Below is an excerpt of the code I would like to implement.
JFrame1 :
public class JFrame1 {
private void button1(java.awt.event.ActionEvent evt){
JFrame2 jf2 = new JFrame2();
jf2.setVisible(true);
this.setVisible(false);
}
}
JFrame2 :
public class JFrame2 {
private void button2(java.awt.event.ActionEvent evt){
this.setVisible(false);
// here the line that would make Jframe1 visible without recreating an instance.
}
}
One last request thing. How can I destroy JFrame2 to free memory space?