Win a copy of Event Streams in Action this week in the Java in General 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Layout problem

 
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
 
Sheriff
Posts: 21775
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write your own layout manager:
 
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?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!