Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Top-align Buttons

Status
Not open for further replies.

cardy

Technical User
Sep 5, 2000
33
GB
I have created a JPanel and set its layout to BoxLayout with components laid out from top to bottom. I then add buttons to the panel but the buttons are centred within the column-shaped panel. How do I get them to "float" to the top ?

TIA

cardy
 
you can add them to another JPanel which has a flowlayout manager, and then add that panel to your box layout.

A box layout only gives you a choice of either X ior Y alignment, both mutually exclusive. If you want a screen with buttons at the top, try using a borderlayout and then add a panel containing the 3 buttons to the NORTH part of the borderlayout.

Box layout is complex to use and is normally only suitable for when there are frame resizing issues you need to address (i.e. it allows you to apply glue to certain compennets whilst letting other float around as the frame is resized etc).

bruce21.jpg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top