File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Position 5 buttons with GridBagConstraints in Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Position 5 buttons with GridBagConstraints in Swing" Watch "Position 5 buttons with GridBagConstraints in Swing" New topic
Author

Position 5 buttons with GridBagConstraints in Swing

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 239
How to position 5 buttons with GridBagConstraints in Swing so that the first button (B1) are at the first column, the next four buttons (B2, B3, B4, B5) are grouped together with some space between the first button and next four buttons, and the fifth button (B5) is placed at the end of the row of the screen?
i.e.
B1          B2B3B4B5
The following code does not work - there is space between each button.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2090
    
    7
Use a horizontal BoxLayout.

Add the first button. Add some "glue". Add the remaining 4 buttons.

See How to Use Box Layout for more information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Position 5 buttons with GridBagConstraints in Swing
 
Similar Threads
help automate code
GridBagConstraints Problem
size of one button is less than expected in GridBagLayout
make the last button align horizontally with other components
how to center this button 1