Hi,

I used the below code to set the 2 buttons width and height.

Java Code:
button1.setPreferredSize(new Dimension(100, 25));
button2.setPreferredSize(new Dimension(100, 25));
After that, I used box layout to align the 2 buttons.

Java Code:
private Box vertical2;

vertical2.add( Box.createRigidArea( new Dimension( 12, 1 ) ) );
vertical2.add (button1);

vertical2.add( Box.createRigidArea( new Dimension( 12, 1 ) ) );
vertical2.add (button2);
But when I check on the output, both button sizes not the same. The button width is based on the button label.

Any help please?