Java Code Examples for javax.swing.ComponentInputMap

The following examples show how to use javax.swing.ComponentInputMap. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: diirt   Source File: CompareResultImages.java    License: MIT License 6 votes vote down vote up
/**
 * Creates new form CompareResultImages
 */
public CompareResultImages() {
    initComponents();
    toReviewList.setModel(new DefaultListModel());
    fillList();
    setSize(800, 600);
    setExtendedState(getExtendedState() | MAXIMIZED_BOTH);
    actualImage.setStretch(false);
    referenceImage.setStretch(false);
    acceptAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control D"));

    InputMap keyMap = new ComponentInputMap(acceptButton);
    keyMap.put(KeyStroke.getKeyStroke("control D"), "accept");

    ActionMap actionMap = new ActionMapUIResource();
    actionMap.put("accept", acceptAction);

    SwingUtilities.replaceUIActionMap(acceptButton, actionMap);
    SwingUtilities.replaceUIInputMap(acceptButton, JComponent.WHEN_IN_FOCUSED_WINDOW, keyMap);
}
 
Example 2
Source Project: netbeans   Source File: OutlineTable.java    License: Apache License 2.0 5 votes vote down vote up
private void filterInputMap(JComponent component, int condition) {
    InputMap imap = component.getInputMap(condition);
    if (imap instanceof ComponentInputMap) {
        imap = new F8FilterComponentInputMap(component, imap);
    } else {
        imap = new F8FilterInputMap(imap);
    }
    component.setInputMap(condition, imap);
}
 
Example 3
Source Project: freecol   Source File: EuropePanel.java    License: GNU General Public License v2.0 5 votes vote down vote up
public EuropeButton(String text, int keyEvent, String command,
                    ActionListener listener) {
    setOpaque(true);
    setText(text);
    setActionCommand(command);
    addActionListener(listener);
    InputMap closeInputMap = new ComponentInputMap(this);
    closeInputMap.put(KeyStroke.getKeyStroke(keyEvent, 0, false),
                      "pressed");
    closeInputMap.put(KeyStroke.getKeyStroke(keyEvent, 0, true),
                      "released");
    SwingUtilities.replaceUIInputMap(this,
                                     JComponent.WHEN_IN_FOCUSED_WINDOW,
                                     closeInputMap);
}