• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Box Layout doubts

 
Gopu Akraju
Ranch Hand
Posts: 242
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 886
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Gopu Akraju
Ranch Hand
Posts: 242
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic