*
The moose likes Swing / AWT / SWT and the fly likes JButton size mystery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButton size mystery" Watch "JButton size mystery" New topic
Author

JButton size mystery

Paul Keohan
Ranch Hand

Joined: Mar 15, 2000
Posts: 411
When I do getSize() of a JButton with text that I've just added to a JPanel it gives me a Dimension width and height of 0, 0. Once I dynamically change the text on the button the Dimensions become different - such as 222, 174. Why is this?
Also, is there a way to maintain the original size of the JButtons when the text on them dynamically changes but still allow the size to change as you drag the frame? When I do this now, my buttons (16 of them sitting on a panel in GridLayout) all change to suit the size of the one button that has the longest text.
Thanks.
Paul
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
It all depends on what layout manager you are using.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
That is the behaviour of GridLayout.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JButton size mystery