I am working on a Java application. The main class frame name as "a". In frame "a", there is one component - jCheckBox. So when I check(tick) this jCheckBox, it open another frame "b". I wanted to untick the jCheckBox when I close frame "b", but it seems like cannot works. Any idea how to solve this? Thanks.
Edit: However, I could close frame "b" by untick the jCheckBox in frame a (in main class frame).What I want to achieve is when I close frame "b", it should automatically uncheck the jCheckBox in frame "a". IDE show me a lot of errors after I compile my apps.
My code: (In Main frame A)
private void jCheckBoxInfoActionPerformed(java.awt.event.ActionEvent evt) {
if (jCheckBoxInfo.isSelected()) {
System.err.println("Frame B is opened");
b.setVisible(true);
} else {
System.err.println("Frame B is closed");
frameInfo.setVisible(false);
}
}
In frame B:
private void formWindowClosing(java.awt.event.WindowEvent evt) {
boolean selected = a.jCheckBoxInfo.isSelected();
System.err.println(selected); //To check the status of jCheckBoxInfo
a.jCheckBoxInfo.setSelected(false); }
Output:
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
at sun.awt.Win32GraphicsConfig.getBounds(Native Method)
at sun.awt.Win32GraphicsConfig.getBounds(Win32GraphicsConfig.java:222)
at java.awt.Window.init(Window.java:505)
at java.awt.Window.<init>(Window.java:537)
at java.awt.Frame.<init>(Frame.java:420)
at java.awt.Frame.<init>(Frame.java:385)
at javax.swing.JFrame.<init>(JFrame.java:189)
at b.<init>(b.java:30)
at a.<init>(a.java:36)
at b.<init>(b.java:26)
at a.<init>(a.java:36)