How to set fixed length for JButton?

Dear friends:

I have three JButtons, so when My panel is 1200 long, three jbuttons evenly occupied all 1200 length, each get 400, looks very ugly,

I hope to reset them with the length I want, e.g, 50 or 100, so

all three buttons can align in west to east 1 by 1 and leave all other area empty. not occupied.

How to set fixed length for JButton at my will?

Thanks

sunny

[412 byte] By [sunnymanmana] at [2007-11-26 22:35:42]
# 1
Use a different layout manager which gives the layout you want. Try FlowLayout.
itchyscratchya at 2007-7-10 11:45:12 > top of Java-index,Desktop,Core GUI APIs...
# 2

add another JPanel between the buttons and the frame

e.g. if you currently add the 3 buttons to a JPanel set as a GridLayout(1,3),

then add that panel to borderlayout.south of a JFrame (1200 wide), your buttons

will all be 400 wide (approx).

if you add the gridlayoutPanel to another panel, then add this other panel to

borderlayout.south, the buttons will all be as wide as the widest of them.

the new panel will take up all the additional space

Michael_Dunna at 2007-7-10 11:45:12 > top of Java-index,Desktop,Core GUI APIs...
# 3
thanks, really good points, Highly appreciated
sunnymanmana at 2007-7-10 11:45:12 > top of Java-index,Desktop,Core GUI APIs...