private void addKeyAction(final IKeyActionConfiguration configuration) { getLayeredPane() .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(configuration.getKeyStroke(), configuration.getActionKey()); getLayeredPane().getActionMap().put(configuration.getActionKey(), configuration.getAction()); }
/** * common constructor for all dialog view elements */ public AbstractDialog(Window owner) { super(owner); setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); setModalityType(ModalityType.APPLICATION_MODAL); setResizable(false); // close dialog on escape this.getLayeredPane().getActionMap().put("close", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { hideWindow(); } }); this.getLayeredPane() .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close"); }
getLayeredPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(escKeyStroke, "esc-pressed");
getLayeredPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(escKeyStroke, "esc-pressed");
getLayeredPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(escKeyStroke, "esc-pressed");
getLayeredPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(escKeyStroke, "esc-pressed");
getLayeredPane().getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( KeyStroke.getKeyStroke( KeyEvent.VK_P, InputEvent.CTRL_MASK ), actionKey ); getLayeredPane().getActionMap().put( actionKey, new AbstractAction() {
getLayeredPane().getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put( KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0 ), actionKey ); getLayeredPane().getActionMap().put( actionKey, new AbstractAction() { @Override