JPanel () { AbstractAction revert = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { revert(); close(); } }; UIUtil.setActionNameAndMnemonic(LocalHistoryBundle.message("action.revert"), revert); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.add(Box.createHorizontalGlue()); p.add(new JButton(revert)); return p; }