File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Minimize button in JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Minimize button in JFrame" Watch "Minimize button in JFrame" New topic

Minimize button in JFrame


Joined: Sep 21, 2001
Posts: 17
after exploring java docs, i could learn how to disable the close button on JFrame, but i could not get anywhere as "How to disable the minimize button on JFrame" ??
can anbody please guide me the way to achieve that?
Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898
I shall try to tell my understanding (it is not an absolute truth):
"The delegation event model is more selective, delivering events only to components that indicate interest in the particular type of event by calling enableEvent(long) or adding a listener to the component."
Window.WINDOW_ICONIFIED event happens without any listener adding. It is because it is OS event, external to application. It is possible to mask/identify it, but not to prevent.
It is possible to catch iconization event but post-factum (minimization already happened) by

and try to de-iconify then.
How to de-iconify? You should to communicate with external world/OS and solution will not be portable... I even do not know your OS...
Any other opinions?
Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898
There was similar but more active discussion earlier in this forum:
Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898
Having a (J)Dialog owned by your (Frame/JFrame) frame, will prevent minimization (but that dialog will be always on top and you may not even make it of "zero" size, peer's menubar, sorry taskbar, with close button will always show up:
import java.awt.*;
import javax.swing.*;
public class TestDesactivateMinimize
public static void main (String args[])
javax.swing.JFrame frame = new javax.swing.JFrame ("JFrame");
JDialog diag = new JDialog (frame, "JDialog", true);
frame.setSize(200, 500);
frame.setLocation(500, 300);
frame.setVisible (true);;;

[This message has been edited by G Vanin (edited November 23, 2001).]
I agree. Here's the link:
subject: Minimize button in JFrame
It's not a secret anymore!