I'm trying to learn Java so sorry if this is a stupid question, but I seem to be unable to change the default close operation on my JFrame in NetBeans.
In NetBeans I created a JFrame and implemented some controls on it using the NetBeans GUI designer. However, I noticed that after I close the JFrame, my application would close even though I have another form that is supposed to appear afterwards.
After digging through the JFrame generated code I found:
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
From research it appears that this causes the application to close when the frame is closed. I would prefer to not have this happen. From looking around, it appears I either need to use DISPOSE_ON_CLOSE or DO_NOTHING_ON_CLOSE in order to get the window to close but still have additional code to run.
However, I can't figure out how to get NetBeans to change this value through the designer. I found the defaultCloseOperation in the Properties -> Bindings window, but every time I enter something into the text area and press enter my text disappears. The binding has an elipsis but I can't figure out what the binding window actually does.
How can I change my setDefaultCloseOperation() to a new value?

It is right there in the properties panel. Just make sure that the whole JFrame is selected. You can select your JFrame from Inspector panel.
Try to update defaultCloseOperation value from Properties -> Properties tab, not binding tab

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With