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

Unevenly laying out a JFrame

Richard Woodward
Greenhorn

Joined: Jan 28, 2010
Posts: 3

Hey all,

I currently have a frame with two JPanel's placed upon it side-by-side (vertically) by using GridLayout:

On my left panel I have a couple of JLabels, a JProgressbar, and a JTable. On the Right I have a JButton.
However, this split of the frame has given equal amount of space for both panels (as you would expect).
I wish to make the right panel much smaller than the left so that the left panel dominates the frame space (around 3:1).
How can this be done? I've been looking around and noticed JSplitpane but that only really seems helpful when you're using one panel.

Cheers,
Ritchie
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

How about a BorderLayout, with the right panel added with BorderLayout.EAST (meaning it will only get its preferred size) and the left panel with BorderLayout.CENTER (meaning it will take up all remaining space)?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Richard Woodward
Greenhorn

Joined: Jan 28, 2010
Posts: 3

That's done the job! Nice one, Rob

Cheers,
Ritchie
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Unevenly laying out a JFrame