• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple java layout question

 
Ranch Hand
Posts: 60
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,

I'm still getting used to layout managers etc, I have a JPanel that is quite large in size, I'm wanting to add another panel to it that looks something like below (the contents of the frame)



However when I add this Panel to a bigger Panel, it screws it



And here's the pretty simple test code I've been using



Thanks,
Paul
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you add the panel to a BorderLayout the size of the component is automatcally changed to take up all the space in the BorderLayout. Since a GridLayout also expands to take up all the space all the components get resized. You can prevent this by wrapping your panel into another panel that uses a layout manager that respects the preferred size of the components. Something like this:

 
Paul Statham
Ranch Hand
Posts: 60
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Camick wrote:When you add the panel to a BorderLayout the size of the component is automatcally changed to take up all the space in the BorderLayout. Since a GridLayout also expands to take up all the space all the components get resized. You can prevent this by wrapping your panel into another panel that uses a layout manager that respects the preferred size of the components. Something like this:



Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic