Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Box Layout doubts

 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 974
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic