Friday, January 26, 2018

java - Netbeans project, JFrames ran from the main JFrame close all JFrames in project

I have a new netbeans "Java application" project, I am trying to add in a second JFrame from the main JFrame in which users can load files from.



So I have the main JFrame main method



public static void main(String args[]) 
{


try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}

java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {

new MainView().setVisible(true);
}
});
}


Which when I hit run this is the JFrame that runs, in the same project I have defined another JFrame object, the input Frame. There is a button in the main frame that when hit, does a .setVisible on the statically defined input JFrame. But if I click "X" on the input frame the main frame also closes?



Any ideas?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...