JButton (Action action) { final JButton button = super.createJButtonForAction(action); if (action == mySwitchModeAction) { int width1 = new JButton(getSwitchButtonText(EvaluationMode.EXPRESSION)).getPreferredSize().width; int width2 = new JButton(getSwitchButtonText(EvaluationMode.CODE_FRAGMENT)).getPreferredSize().width; final Dimension size = new Dimension(Math.max(width1, width2), button.getPreferredSize().height); button.setMinimumSize(size); button.setPreferredSize(size); } return button; }