3

I have a simple GUI program that creates a new window (which contains a JTable) at some point in time. If the user closes the JTable, the main application closes as well. How do I prevent this? Would it have something to do with how it handles the window closing, or should I give it it's own thread, or what?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • My guess is that your main thread already finished, causing the entire program to shut down when the window is closed. Can you post the (relevant parts of) your code? – Keppil Sep 02 '12 at 21:36
  • 1
    the user can't close the JTable, but is closing the window or JFrame. JTable is a component only –  Sep 02 '12 at 21:38
  • See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson Sep 04 '12 at 00:58

1 Answers1

7

Set one of these close operation for your JFrame: HIDE_ON_CLOSE or DISPOSE_ON_CLOSE. You are using EXIT_ON_CLOSE. Here is a link to the JavaDoc method you can use.

Baz
  • 36,440
  • 11
  • 68
  • 94