sclass DefaultButtonBorder extends JPanel { JButton button; *(JButton *button) { super(new BorderLayout); setBorder(makeBorder()); add(button); onEnabledChanged(button, -> setBorder(makeBorder())); } Border makeBorder() { ret BorderFactory.createLineBorder(main isEnabled(button) ? Color.black : Color.lightGray); } }