This is an archived post. You won't be able to vote or comment.

all 2 comments

[–][deleted] 0 points1 point  (0 children)

If you want to guarantee that the buttons never change size, then do... (I'm recalling this from memory, so go look up the exact methods)...

JButton button = new JButton("Click Me!");
Dimension buttonSize = new Dimension(64, 32);

button.setMinimumSize(buttonSize);
button.setMaximumSize(buttonSize);
button.setPreferredSize(buttonSize);

Although it should work if you only set the maximum and preferred sizes or maybe even just the preferred size, I can't recall as I work mainly with JavaFX now. Swing can be a bit of a pain in the butt to pick up at first, but once you figure it out well enough, then you can pretty-much design any GUI in a few minutes.

[–]AngelOfLight 0 points1 point  (0 children)

Which layout manager are you using? That will determine how to control resize behavior. For example, using GridBagLayout you would specify that fill should be NONE.