File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Setting frame minimum size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Setting frame minimum size" Watch "Setting frame minimum size" New topic
Author

Setting frame minimum size

Anna Hays
Ranch Hand

Joined: Nov 09, 2003
Posts: 131
Hi, I am trying to make the frame to have a minimum size so that it won't resize to one pixel. There are 2 ways I can think of to do this.

1. make the frame to have a minimum size.
2. make all main (in the content pane) components to have a minimum size so that if I add another one, the minimised frame will still show all components.

Since I can't find frame can set a minimum size, so 2 is the way to go. And I think 2 is better way as well, am I right? Should the frame have a minimum size too?

Thanks for any advice.
Anna Hays
Ranch Hand

Joined: Nov 09, 2003
Posts: 131
Hi again, just realise 2 won't work. I have give the components a minimum size, but the frame can still resize pass the minimum size. Can someone help me please?
Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
Hi, Anna. I think this may be a good solution. The componentResized event handler could set the minimum size.



... the Adapter:



Hope this info is what you are looking for I hope the mechanism will be helpful to your project.

Sincerely,

Anton.

[ October 16, 2004: Message edited by: Anton Golovin ]
[ October 16, 2004: Message edited by: Anton Golovin ]

Anton Golovin (anton.golovin@gmail.com) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Here's the code to do that, implemented as an anonymous inner class:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Setting frame minimum size