wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Positioning controls on a GridBagLayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Positioning controls on a GridBagLayout" Watch "Positioning controls on a GridBagLayout" New topic

Positioning controls on a GridBagLayout

Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
I have a GridbagLayout which has a JButton on the left and 2 JComboBoxes
on the right. How can I set the contraints so if the panel is stretched
the 2 combo boxes remain on the right of the panel?

Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
You should create your constraints so the right hand has a higher weight. For example.

constraint = new GridBagConstrait(1,1, 1,1, 1.0, 1.0 etc...

If you post some code I'll be glad to help you out.
It is sorta covered in the JavaRanch Style Guide.
subject: Positioning controls on a GridBagLayout
Similar Threads
Problems positioning buttons in GridBagLayout
How can i open a paenl thru ActionPerformed
Problem in JDialogBox
GridLayout with weightx