0

I'm back again :P I have this program that opens up a window. There's options menu that opens in a new window and what I want to happen is when I close the options window, it doesn't shut the program down. I know that

setDefaultCloseOperation(); 

Will close down my window but I looked at the documentation and it doesn't have a solution for my problem. Can anyone be kind enough to help? Thanks (:

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278

1 Answers1

5
// different close actions are available, that do different things!
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 

But see also, The Use of Multiple JFrames: Good or Bad Practice? Sneak preview, the answer is: Bad (bad, bad) practice.

..(will) look into other window managers

It is not so much 'window' managers we need here as 'view' managers. Those views (e.g. each in a panel) might then be managed by dialogs, option panes, pop-ups, tool bars, layout managers, (very rarely) other frames or windows..

The content you mention seems well suited to being displayed in a (possibly modal) dialog.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • Huh ok ill look into other window managers, thanks for all the tips –  Sep 08 '12 at 23:29