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

use 80% of a row

Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
Hi!

I have panel that has a scroll pane (with an editor pane) and a button. I would like that the scroll pane filled 80% of the panel. Is there a way to do this? How?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Check out weightx and weighty in GridBagLayout


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
another option is BorderLayout.

put everything else in a separate panel, then add that to EAST/WEST/NORTH or SOUTH,
giving it a preferredSize width or height (depending on where it is in the BorderLayout) equal to 20% of the frame's width or height,
then add the scrollpane to BorderLayout.CENTER, and it will take up the remaining 80%
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
Thank you.

I tried the below code but it didn't work. It is 50% for both. I'll try Michael Dunn's suggestion and give feedback.

pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Leandro Coutinho wrote:Thank you.

I tried the below code but it didn't work. It is 50% for both.

No surprise as you're using GridLayout not the suggested GridBagLayout. There's a BIG difference.

Luck
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
pete stein wrote:
Leandro Coutinho wrote:Thank you.

I tried the below code but it didn't work. It is 50% for both.

No surprise as you're using GridLayout not the suggested GridBagLayout. There's a BIG difference.

Luck

wow. sorry folks. (ashamed)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use 80% of a row