• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disabling The Maximize Box And The Close Box

 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to disable the maximize button in a Window?

Is there also a way to disable the close box on a modal JDialog and force the user to use a JButton to dismiss the dialog (yet still have a title bar)?

Kaydell
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to disable the maximize button in a Window?
You can use the index to look up the setResizable method (links at top of any api
page) to find which classes have it. Frame and Dialog yes, Window no.
Is there also a way to disable the close box on a modal JDialog and force the user to use
a JButton to dismiss the dialog (yet still have a title bar)?

Probably. You might have to write some plaf code.
Other options:
1 — use a JWindow or undecorated JFrame and add or draw a "title bar"
2 — use a JOptionPane which will return null if the dialog is disposed with the close button
3 — add a WindowListener to the dialog and do what you need before the dialog is disposed.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Is there also a way to disable the close box on a modal JDialog

if you just want to disable the 'X'
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

or do you want to remove the 'X'?
 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

< Is there a way to disable the maximize button in a Window?

...look up the setResizable method...


Thanks, that worked. Now the Maximize box is still in my title bar, but it's disabled, The Iconify box was already disabled because I'm using a JDialog instead of a JFrame.
 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>> Is there also a way to disable the close box on a modal JDialog

> if you just want to disable the 'X'
> dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

> or do you want to remove the 'X'?

I did want to entirely remove the close box, but setting the default close operation is good stuff. Now I get a windowClosing WindowEvent and my program has control.

Also, for my JFrames that need to save data to the file-system or to a database, now get notified via the windowClosing() WindowEvent and I get a chance to save.

Kaydell
[ May 24, 2007: Message edited by: Kaydell Leavitt ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic