Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

BorderLayout...

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all...
Can someone tell me how can v set the components
height using borderLayout when the component is placed
either in North or South.
i.e. i tried using setSize() but the componet height
was same.
According to BorderLayout, a components preferred height will be honored when attached to Norht or South.
Thanks
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<quote>
According to BorderLayout, a components preferred height will be honored when attached to Norht or South.
</quote>
When components preferred height will be HONORED ..How can u change it !!
I think ..u can't.
Anybody >>>>>>>>>
 
Shah Chunky
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What i wanted to know is that can u set the height of a component
if u place it in North or South...
Thanks
[This message has been edited by Shah Chunky (edited April 21, 2001).]
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You were correct in saying that BorderLayout honors the preferred height for north and south positioned components.
Preferred size is determined by Component.getPreferredSize(). I believe by default an AWT component gets this information from its peer but of course you can override it and thereby set any dimension you want. With Swing components, you can change the preferred size by simply using JComponent.setPreferredSize().
Here's a snippet of the source code to BorderLayout's layoutContainer method:

So you can see that it really does use the preferred size for north and south positions. Also, here's some code that demonstrates setting the size of a northern positioned AWT button:

(My first time answering someone's question on here! Let's hope I'm right... )
- Dave

[This message has been edited by Dave Terrian (edited April 21, 2001).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic