different size og JButton

i am making a calculator which is JFrame and there r 3 JPanels in out of which two panels follow Gridlayout but the button size of buttons these two panels is different and i want them to be be same, if somebody could help..

only defference i feel is in constructor of GridLayout objects in these panels

panel1 has : GridLayout(0,6,4,4);

panel2 has : GridLayout(1,3,4,4,);

[397 byte] By [shagya] at [2007-11-27 10:24:37]
# 1

I don't understand the question. One grid has 6 columns the other has 3 columns. Of course the widths will be different.

If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",

see http://homepage1.nifty.com/algafield/sscce.html,

that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

Don't forget to use the "Code Formatting Tags",

see http://forum.java.sun.com/help.jspa?sec=formatting,

so the posted code retains its original formatting.

camickra at 2007-7-28 17:28:59 > top of Java-index,Desktop,Core GUI APIs...
# 2

only difference in gridlayout is one has 3 coloumn and another has 6

but the buttons that r added in panel1 are twice the size of buttons in panel2

so, when did not any where specify the size of button than how come two panels have different size of buttons

shagya at 2007-7-28 17:28:59 > top of Java-index,Desktop,Core GUI APIs...
# 3

The buttons are sized to fill the entire width available to the panel.

camickra at 2007-7-28 17:28:59 > top of Java-index,Desktop,Core GUI APIs...
# 4

You can try to use BoxLayout and set the JButton size by:

panel1.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

JButton.setMinimumSize(new Dimension(50, 35));

JButton.setMaximumSize(new Dimension(50, 35));

JButton.setPreferredSize(new Dimension(50, 35));

jiong_ronga at 2007-7-28 17:28:59 > top of Java-index,Desktop,Core GUI APIs...
# 5

thanks buddy , i worked

another question, what is the difference b/w using setMaximumSize

and setBounds...

and what does setPreferredSize() do , i did not find API dovumentation very clear

shagya at 2007-7-28 17:28:59 > top of Java-index,Desktop,Core GUI APIs...
# 6

This is better way to fit JButton size on BoxLayout.

Use new Dimension() is better than Bound in BoxLayout(), coz setBound is usually good in Layout(null), example create a game application, to move object on a layout(null).

BoxLayout can make design sequence and tidy in looks for your current application.

jiong_ronga at 2007-7-28 17:28:59 > top of Java-index,Desktop,Core GUI APIs...