This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to Disable Minimize button in JFrame ? - URGENT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to Disable Minimize button in JFrame ? - URGENT " Watch "How to Disable Minimize button in JFrame ? - URGENT " New topic
Author

How to Disable Minimize button in JFrame ? - URGENT

Pratik Khetia
Ranch Hand

Joined: Jun 29, 2001
Posts: 50
I want to disable the minimize button and stop it from going to the windows taskbar.
Is there anyway I can do it ??
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
if its a JInternalFrame: setIconable(false);
if its a JFrame:
addWindowListener(new WindowAdapert()
{
public void windowIconified(WindowEvent e)
{
// reopen
}
});
unfortunately, there is no event to notify you that the frame is going to be iconified. you should consider using an JInternalFrame (if its not the main window of your app) or a JDialog.
chantal
george justin
Greenhorn

Joined: Jul 31, 2001
Posts: 25
Hi
I think, setting the property of JFrame, setResizable(false); should do it

JFrame f = new JFrame();
f.setResizable(false);
Cheers
George Justin
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
George,
You can't remove the window decorations from within Java on JFrame because the underlaying OS draws the frame.
Resizable just stops a user from enlarging or shrinking the frame. It doesn't affect OS operations at all (i.e., iconification, closing, etc).
Regards,
Manfred.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You could make it a JWindow... it doesn't have any window decorations at all, so it can't be minimized...

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Pratik Khetia
Ranch Hand

Joined: Jun 29, 2001
Posts: 50
Originally posted by Nathan Pruett:
You could make it a JWindow... it doesn't have any window decorations at all, so it can't be minimized...

-Nate


But I can't even close that window. It doesn't show anything like no close button. I can not even move that window.
Could you tell me how to do that ??
Pratik
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Make a graphic for a close button, load it as an imageicon, and add it to a JButton. Put that JButton in the upper right hand corner, and in it's actionListener that closes the window or exits the program. Moving the window is a bit more of a problem... you'll either have to add a component that listens for the movement (like have a JPanel that listens for mousePressed events, and any mousePressed event in it lets you move the frame) or have the whole frame listen for the movement. I personally think that a special component is better, because you can change it's color or something to show that it's seperate from the display area.

The following code is a bit crude, but it illustrates these ideas:



-Nate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Disable Minimize button in JFrame ? - URGENT
 
Similar Threads
How do you maximize on frame load?
Disabling minimize and maximie button
JFrame problems.....
JFrame disable minimize button (jdk1.3)
Minimize button in JFrame