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);
}
}
}
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);
}
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);
}
Aggregations