Problems resizing JButtons

Hi. I have a GUI with a JPanel to which I have added 43 JButtons. I use a for loop to add the buttons but I cannot set the size of individual buttons. I want two of the buttons to be bigger than the rest. Can anyone please help me
[244 byte] By [carrolf2] at [2007-9-26 1:15:47]
# 1
What layout manager are you using?You may try with GridBagLayout, it is a bit complicated but quite powerfull.Take a look at this tutorial: http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html
DanielN at 2007-6-29 0:42:39 > top of Java-index,Archived Forums,Swing...
# 2
You can get the default size of the buttons by calling getPreferredSize().Then you might want to set the explicit size of the button, then you should call all setXXXSize() methods. (min, max, pref.)Kurta
h230561 at 2007-6-29 0:42:39 > top of Java-index,Archived Forums,Swing...
# 3

> Hi. I have a GUI with a JPanel to which I have added

> 43 JButtons. I use a for loop to add the buttons but I

> cannot set the size of individual buttons. I want two

> of the buttons to be bigger than the rest. Can anyone

> please help me

As some else has mentioned, much depends on your

layout manager. You be able to do the job with

GridBagLayout, but if that's too much like hard

work, you can always turn the panel's layout manager off

and manually place & size each of your buttons.

setLayout( null );

and for each button:

button.setBounds( x, y, width, height );

If you do this, the buttons won't move or expand

when the panel is resized. I reckon that's not

a bad thing for buttons anyway.

greg_breen at 2007-6-29 0:42:39 > top of Java-index,Archived Forums,Swing...