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

Grid Layout Problems

Brian Batson
Greenhorn

Joined: Jun 15, 2011
Posts: 11
Howdy!

I am using a GridLayout to display a variety of information. It's working just fine but I really wish I could set the width of the columns (like a JTable) for the columns within the GridLayout.

See the attached screen shot for a sample (assume the JLabels are different from the first and second columns).

As you can see, the GridLayout evenly spaces the columns, although I would prefer for the columns holding the JLabels to be much smaller than the size for the columns holding the JTextFields.

Any guidance that you can provide is very much appreciated.


[Thumbnail for grid_layout_sample.jpg]

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2227
    
    8
A GridLayout won't do what you want.

Read up on Layout Managers. A SpringLayout or GridBagLayout would be your best bet.
Brian Batson
Greenhorn

Joined: Jun 15, 2011
Posts: 11
Awesome, thanks, Rob. Somehow I missed SpringLayout in my initial cursory review of available layouts. The SpringForm mentioned about 3/4 down the following webpage addresses my needs completely: http://download.oracle.com/javase/tutorial/uiswing/layout/spring.html

Thanks, again.

-Brian
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Also Google for MigLayout. I have never tried it, but those who have say it's very good.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Grid Layout Problems