This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Layout problem

 
Akhil Jain
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Please help me out in this, i wanna set the layout of a panel such that, that 60% of its width is covered by one another sub-panel and 40% by another sub-panel, i tried using BorderLayout and tried setting first sub-panel at CENTER and second sub-panel at LINE_END, but the first panel is taking too much space. something like: as shown in pic.



I wanna use a GridBagLayout here, but not getting a way to provide 60-40 ratio to these sub-panels.

Note: Can't use any other layout here, since my application window is re-sizable, hence after re-sizing, both the panels should re-size along with their parent panel in exactly the same ratio.

looking forward for some reply with explanation.


Regards,
Akhil
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write your own layout manager:
 
Mattias Johansson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't you set the width of the left sub panel to 60% of the main panel and 40% on the right one. Then you put a listener on the split pane and adjust the width of these if you change the size of the split pane?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just use the GridBagConstraints.weightx attribute - it takes a double which it expects to use as a percentage (i.e. use values between 0..1).

 
Akhil Jain
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys,

that helped me a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic