aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Layout problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Layout problem" Watch "Layout problem" New topic
Author

Layout problem

Akhil Jain
Ranch Hand

Joined: Oct 14, 2004
Posts: 74
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


-------------------------------<br />you can't move ahead, unless you try for it.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19785
    
  20

You can write your own layout manager:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Mattias Johansson
Greenhorn

Joined: Oct 21, 2007
Posts: 11
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

Joined: Oct 18, 2000
Posts: 4121

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).



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Akhil Jain
Ranch Hand

Joined: Oct 14, 2004
Posts: 74
thanks guys,

that helped me a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Layout problem