This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Disable Minimize button in JFrame ? - URGENT

 
Pratik Khetia
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could make it a JWindow... it doesn't have any window decorations at all, so it can't be minimized...

-Nate
 
Pratik Khetia
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic