public TristateCheckBox(String text, Icon icon, Boolean initial) { super(text, icon); // Add a listener for when the mouse is pressed super.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { grabFocus(); decorator.nextState(); } }); // Reset the keyboard action map ActionMap map = new ActionMapUIResource(); map.put("pressed", new AbstractAction() { //NOI18N public void actionPerformed(ActionEvent e) { grabFocus(); decorator.nextState(); } }); map.put("released", null); //NOI18N SwingUtilities.replaceUIActionMap(this, map); // set the model to the adapted model decorator = new TristateDecorator(getModel()); setModel(decorator); setState(initial); }
/** * {@inheritDoc} */ @Override protected void installKeyboardActions() { // NOTE: Don't call super.installKeyboardActions(), as that causes // JTextAreas to stop responding to certain keystrokes if an RTextArea // is the first-instantiated text area. This is because of the code // path installKeyboardActions() -> getActionMap() -> createActionMap(). // In BasicTextUI#createActionMap(), "editor.getActions()" is called, // and the current editor's returned Actions are used to create the // ActionMap, which is then cached and used in all future J/RTextAreas. // Unfortunately, RTextArea actions don't worn in JTextAreas. //super.installKeyboardActions(); RTextArea textArea = getRTextArea(); // backward compatibility support... keymaps for the UI // are now installed in the more friendly input map. textArea.setKeymap(createKeymap()); // Since BasicTextUI.getInputMap() is package-private, instead use // our own version here. InputMap map = getRTextAreaInputMap(); SwingUtilities.replaceUIInputMap(textArea,JComponent.WHEN_FOCUSED,map); // Same thing here with action map. ActionMap am = getRTextAreaActionMap(); if (am!=null) { SwingUtilities.replaceUIActionMap(textArea, am); } }
protected void installKeyboardActions() { ActionMap map = getActionMap(); if (map != null) { SwingUtilities.replaceUIActionMap(tipPane, map); } }
protected void uninstallKeyboardActions() { SwingUtilities.replaceUIActionMap(menuItem, null); if (windowInputMap != null) { SwingUtilities.replaceUIInputMap(menuItem, JComponent. WHEN_IN_FOCUSED_WINDOW, null); windowInputMap = null; } }
protected void uninstallKeyboardActions() { SwingUtilities.replaceUIActionMap(menuItem, null); if(windowInputMap != null) { SwingUtilities.replaceUIInputMap(menuItem, JComponent.WHEN_IN_FOCUSED_WINDOW, null); windowInputMap = null; } }
protected void uninstallKeyboardActions(JScrollPane c) { SwingUtilities.replaceUIActionMap(c, null); SwingUtilities.replaceUIInputMap(c, JComponent. WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null); }
protected void installKeyboardActions() { ActionMap map = getActionMap(); if (map != null) { SwingUtilities.replaceUIActionMap(tipPane, map); } }
protected void uninstallKeyboardActions() { SwingUtilities.replaceUIActionMap(menuItem, null); if (windowInputMap != null) { SwingUtilities.replaceUIInputMap(menuItem, JComponent. WHEN_IN_FOCUSED_WINDOW, null); windowInputMap = null; } }
protected void uninstallKeyboardActions() { SwingUtilities.replaceUIInputMap(_popup, JComponent. WHEN_IN_FOCUSED_WINDOW, null); SwingUtilities.replaceUIActionMap(_popup, null); }
protected void installKeyboardActions() { ActionMap map = getActionMap(); if (map != null) { SwingUtilities.replaceUIActionMap(tipPane, map); } }
/** * Removes the focus InputMap and ActionMap. */ protected void uninstallKeyboardActions() { SwingUtilities.replaceUIInputMap( comboBox, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null); SwingUtilities.replaceUIActionMap(comboBox, null); }
protected void installKeyboardActions() { ActionMap actionMap = getActionMap(); SwingUtilities.replaceUIActionMap(menuItem, actionMap); updateAcceleratorBinding(); }
protected void uninstallKeyboardActions() { editor.setKeymap(null); SwingUtilities.replaceUIInputMap(editor, JComponent.WHEN_IN_FOCUSED_WINDOW, null); SwingUtilities.replaceUIActionMap(editor, null); }
protected void uninstallKeyboardActions() { SwingUtilities.replaceUIActionMap(tabPane, null); SwingUtilities.replaceUIInputMap( tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null); SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_FOCUSED, null); }
@Override protected void installListeners(JFileChooser fc) { super.installListeners(fc); ActionMap actionMap = getActionMap(); SwingUtilities.replaceUIActionMap(fc, actionMap); }
@Override protected void uninstallKeyboardActions() { AbstractButton b = menuItem; SwingUtilities.replaceUIInputMap(b, JComponent. WHEN_IN_FOCUSED_WINDOW, null); SwingUtilities.replaceUIInputMap(b, JComponent.WHEN_FOCUSED, null); SwingUtilities.replaceUIActionMap(b, null); super.uninstallKeyboardActions(); }
protected void installKeyboardActions(JScrollPane c) { InputMap inputMap = getInputMap(JComponent. WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); SwingUtilities.replaceUIInputMap(c, JComponent. WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap); ActionMap actionMap = getActionMap(); SwingUtilities.replaceUIActionMap(c, actionMap); }
protected void uninstallListeners(VFSJFileChooser fc) { if (propertyChangeListener != null) { fc.removePropertyChangeListener(propertyChangeListener); } fc.removePropertyChangeListener(getModel()); SwingUtilities.replaceUIInputMap(fc, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null); SwingUtilities.replaceUIActionMap(fc, null); }
/** * Invoked as part from the boilerplate install block. */ protected void installKeyboardActions() { InputMap km = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); SwingUtilities.replaceUIInputMap(graph, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, km); km = getInputMap(JComponent.WHEN_FOCUSED); SwingUtilities.replaceUIInputMap(graph, JComponent.WHEN_FOCUSED, km); SwingUtilities.replaceUIActionMap(graph, createActionMap()); }
SwingUtilities.replaceUIActionMap(this, map);