File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How to let a dialog be maximized Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to let a dialog be maximized" Watch "How to let a dialog be maximized" New topic
Author

How to let a dialog be maximized

Tom McC
Greenhorn

Joined: Jul 28, 2005
Posts: 21
Hello,

I have class that extends a non-modal JDialog box (the only way I could find to easily have an always-on-top window), and I'd like to add the ability to maximize it. Of course, I can add a button myself that will just make its dimensions the same as the screen, but I wondered if there was a solution that would let me have the normal OS-type maximize button in the title bar.

Thanks!
Tom
Brian Duff
Greenhorn

Joined: Aug 16, 2001
Posts: 22
Is the dialog set to be resizable (with Dialog.setResizable( true ))?

Brian
Tom McC
Greenhorn

Joined: Jul 28, 2005
Posts: 21
Brian,

I tried explicity making it resizable to no avail; I can resize it fine, but no maximize button...it kind of makes sense that a dialog wouldn't be able to be maximized, but it doesn't make sense that I need to make a window a dialog just to get it to be on top :roll:

Thanks anyway---I'm ending up just making a button to maximize/restore the window myself.

Tom
Pat Hays
Ranch Hand

Joined: Aug 20, 2004
Posts: 138
Hello Tom

Try the following code instead.
---------------
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;

this.setSize(screenWidth, screenHeight);


Download Java GUI Builder, <a href="http://www.mars3000.com" target="_blank" rel="nofollow">http://www.mars3000.com</a>
Tom McC
Greenhorn

Joined: Jul 28, 2005
Posts: 21
As an update, I did manage to find a class someone made to let a JFrame act in many ways like a modal dialog (with a maximize button!). This doesn't quite fit my purposes, as I only want the on-top functionality, not the modality, but I wanted to share the link:
Are you missing a maximize button on JDialog?


Thanks Pat, for the suggestion; this code works also, for anyone who's interested:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to let a dialog be maximized
 
Similar Threads
Add maximize button to portlet
JInternalFrame problem
How to redirect to any other portlet on clicking Normal or Maximized icon of portlet
Positioning of JButton
window maximize/restore events