Two Laptop Bag
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Setting frame minimum size Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply 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: 473
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<br /><i>anton.golovin@gmail.com</i><br />SCJP, SCJD, SCBCD, SCWCD
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Here's the code to do that, implemented as an anonymous inner class:
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Setting frame minimum size
 
Similar Threads
JFrame and JTable
Enforcing Minimum Size in Frames
Liquid LayoutManager
How to stop JTextField collapsing when using GridBagLayout?
GUI: Should we make the window size resizable?