JButton (Action action) { JButton button = createJButtonForAction(action, getRootPane()); int mnemonic = button.getMnemonic(); Object name = action.getValue(Action.NAME); if (mnemonic == KeyEvent.VK_Y && "Yes".equals(name)) { myYesAction = action; } else if (mnemonic == KeyEvent.VK_N && "No".equals(name)) { myNoAction = action; } if (action.getValue(FOCUSED_ACTION) != null) { myPreferredFocusedComponent = button; } return button; }