user1650305
user1650305

Reputation:

Dispose window without shutting down whole program

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 (:

Upvotes: 0

Views: 143

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168845

// 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.

Upvotes: 5

Related Questions