Search in sources :

Example 6 with ComponentInputMapUIResource

use of javax.swing.plaf.ComponentInputMapUIResource in project adempiere by adempiere.

the class CompiereLabelUI method installKeyboardActions.

//	createUI
/**
	 * 	Install Keyboard Actions
	 *	@param l label
	 */
protected void installKeyboardActions(JLabel l) {
    //	super.installKeyboardActions(l);
    int dka = l.getDisplayedMnemonic();
    if (dka != 0) {
        Component lf = l.getLabelFor();
        if (lf != null) {
            ActionMap actionMap = l.getActionMap();
            actionMap.put(PRESS, ACTION_PRESS);
            InputMap inputMap = SwingUtilities.getUIInputMap(l, JComponent.WHEN_IN_FOCUSED_WINDOW);
            if (inputMap == null) {
                inputMap = new ComponentInputMapUIResource(l);
                SwingUtilities.replaceUIInputMap(l, JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);
            }
            inputMap.clear();
            inputMap.put(KeyStroke.getKeyStroke(dka, ActionEvent.SHIFT_MASK + ActionEvent.CTRL_MASK, false), PRESS);
        }
    }
}
Also used : ComponentInputMapUIResource(javax.swing.plaf.ComponentInputMapUIResource) ActionMap(javax.swing.ActionMap) InputMap(javax.swing.InputMap) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Example 7 with ComponentInputMapUIResource

use of javax.swing.plaf.ComponentInputMapUIResource in project adempiere by adempiere.

the class CCheckBox method setMnemonic.

// createMnemonic
/**
	 * Overrides the JCheckBox.setMnemonic() method, setting modifier keys to
	 * CTRL+SHIFT.
	 * 
	 * @param mnemonic
	 *            The mnemonic character code.
	 */
public void setMnemonic(int mnemonic) {
    super.setMnemonic(mnemonic);
    InputMap map = SwingUtilities.getUIInputMap(this, JComponent.WHEN_IN_FOCUSED_WINDOW);
    if (map == null) {
        map = new ComponentInputMapUIResource(this);
        SwingUtilities.replaceUIInputMap(this, JComponent.WHEN_IN_FOCUSED_WINDOW, map);
    }
    map.clear();
    String className = this.getClass().getName();
    // Default Buttons
    int mask = InputEvent.ALT_MASK;
    if (// In Tab
    this instanceof JCheckBox || className.indexOf("VButton") != -1)
        mask = InputEvent.SHIFT_MASK + InputEvent.CTRL_MASK;
    map.put(KeyStroke.getKeyStroke(mnemonic, mask, false), "pressed");
    map.put(KeyStroke.getKeyStroke(mnemonic, mask, true), "released");
    map.put(KeyStroke.getKeyStroke(mnemonic, 0, true), "released");
    setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, map);
}
Also used : JCheckBox(javax.swing.JCheckBox) ComponentInputMapUIResource(javax.swing.plaf.ComponentInputMapUIResource) InputMap(javax.swing.InputMap)

Example 8 with ComponentInputMapUIResource

use of javax.swing.plaf.ComponentInputMapUIResource in project adempiere by adempiere.

the class CButton method setMnemonic.

// setActionCommand
/**
	 * Overrides the JButton.setMnemonic() method, setting modifier keys to
	 * CTRL+ALT.
	 * 
	 * @param mnemonic
	 *            The mnemonic character code.
	 */
public void setMnemonic(int mnemonic) {
    super.setMnemonic(mnemonic);
    // Angelo Dabala' (genied) avoid to register Ctrl+Alt modifier mask without mnemonic
    if (mnemonic == KeyEvent.VK_UNDEFINED) {
        return;
    }
    InputMap map = SwingUtilities.getUIInputMap(this, JComponent.WHEN_IN_FOCUSED_WINDOW);
    if (map == null) {
        map = new ComponentInputMapUIResource(this);
        SwingUtilities.replaceUIInputMap(this, JComponent.WHEN_IN_FOCUSED_WINDOW, map);
    }
    map.clear();
    // Default
    int mask = InputEvent.ALT_MASK + InputEvent.CTRL_MASK;
    // Buttons
    map.put(KeyStroke.getKeyStroke(mnemonic, mask, false), "pressed");
    map.put(KeyStroke.getKeyStroke(mnemonic, mask, true), "released");
    map.put(KeyStroke.getKeyStroke(mnemonic, 0, true), "released");
    setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, map);
}
Also used : ComponentInputMapUIResource(javax.swing.plaf.ComponentInputMapUIResource) InputMap(javax.swing.InputMap)

Aggregations

ComponentInputMapUIResource (javax.swing.plaf.ComponentInputMapUIResource)8 InputMap (javax.swing.InputMap)6 JCheckBox (javax.swing.JCheckBox)3 Component (java.awt.Component)2 ActionMap (javax.swing.ActionMap)2 JComponent (javax.swing.JComponent)2