I am currently porting my Android app to a desktop app using Java (Swing, NetBeans).
I need a main java window and several pop-up forms for user IO. In the android app I have been using activities, eg: startActivity(anotherActivity)
. I am currently using a JFrame for each pop-up form in the PC app I have been using setVisible
to simulate opening the forms from menu actions and other event logic, but hitting the close button on any of the pop-up forms closes the entire app, not just the form. Should I be using something other than setVisible(true|false)
? Should I be using something other than JFrames such as a JPanel or JDialog? Should I override close()
on my child forms to do setVisible(false)
? Unfortunately, I am learning Java, Swing, and NetBeans on the fly so the best approach to these types of problems is not obvious (to me).
Edit: Why is the auto generated code in initComponents()
set to EXIT_ON_CLOSE
when the defaultCloseOperation
is set to HIDE
in the swing form properties?