Terai Atsuhiro 2021-09-15 (水) 10:31:09

http://terai.s55.xrea.com/swing/buttonwidth/screenshot.png

Dimension dim = button1.getPreferredSize();
button1.setPreferredSize(new Dimension(100, dim.height));
button2.setPreferredSize(new Dimension(100, dim.height));
Box box1 = Box.createHorizontalBox();
box1.add(Box.createHorizontalGlue());
box1.add(button1);
box1.add(Box.createHorizontalStrut(5));
box1.add(button2);
box1.add(Box.createHorizontalStrut(5));
box1.add(Box.createRigidArea(new Dimension(0, dim.height+10)));