permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes Box Layout doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Box Layout doubts" Watch "Box Layout doubts" New topic
Author

Box Layout doubts

Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
I am adding 5 panels in box layout. Is tehre any way I can change the height of each panel in the final diaplay. B'cos few panels contain buttons and few contain JTextArea. Right now all the panels carry equal weight or equal height. I want to reduce the height for the panel with buttons and more height for panels with JTextArea. Thanks.
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Originally posted by Gopu Akraju:
I am adding 5 panels in box layout. Is tehre any way I can change the height of each panel in the final diaplay. B'cos few panels contain buttons and few contain JTextArea. Right now all the panels carry equal weight or equal height. I want to reduce the height for the panel with buttons and more height for panels with JTextArea.


You don't say whether your BoxLayout uses X_AXIS or Y_AXIS, but either way I don't see why it would be giving each panel the same height unless they all had the same preferred height (by which I mean getPreferredSize().height).

Typically a JPanel containing a JTextArea would have a larger preferred height than a JPanel containing some JButtons, so I'm not sure what to say in the absence of further details.

[edit: Actually, I take that back. The JTextArea's preferred size will be just enough to display its content, so if there's not much text in it then it's preferred size may be very small. In this case, you may want to fix this by calling setColumns()/setRows() on the JTextArea, or setPreferredSize() on the JTextArea, it's JScrollPane, or it's JPanel.]

I take it you're sure you're not actually using GridLayout somehow.
[ April 10, 2008: Message edited by: Brian Cole ]

bitguru blog
Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
yes, I am using BoxLayout

But I did'nt modify anything with getPreferredSize().height I am using only default values. Just openend Box layout and added all my 5 panels into it. Do you mean to say I can set the height using getPreferredSize().height? Thanks.
[ April 10, 2008: Message edited by: Gopu Akraju ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Box Layout doubts
 
Similar Threads
Resizing Layout with change in Screen Resolution
Problem with GridLayout.
Regarding JComboBox width size
IBM Mock question
Help sorting out what combination of layouts will provide the result I need