use of javax.swing.plaf.ComponentInputMapUIResource in project adempiere by adempiere.
the class CompiereButtonListener method updateMnemonicBindingX.
// propertyChange
/**
* Update Mnemonic Binding
* @param b button
*/
void updateMnemonicBindingX(AbstractButton b) {
int m = b.getMnemonic();
if (m != 0) {
InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW);
if (map == null) {
map = new ComponentInputMapUIResource(b);
SwingUtilities.replaceUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW, map);
}
map.clear();
String className = b.getClass().getName();
// Default Buttons
int mask = InputEvent.ALT_MASK;
if (// In Tab
b instanceof JCheckBox || className.indexOf("VButton") != -1)
mask = InputEvent.SHIFT_MASK + InputEvent.CTRL_MASK;
map.put(KeyStroke.getKeyStroke(m, mask, false), "pressed");
map.put(KeyStroke.getKeyStroke(m, mask, true), "released");
map.put(KeyStroke.getKeyStroke(m, 0, true), "released");
} else {
InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW);
if (map != null)
map.clear();
}
}
use of javax.swing.plaf.ComponentInputMapUIResource in project jdk8u_jdk by JetBrains.
the class BasicButtonListener method updateMnemonicBinding.
/**
* Resets the binding for the mnemonic in the WHEN_IN_FOCUSED_WINDOW
* UI InputMap.
*/
void updateMnemonicBinding(AbstractButton b) {
int m = b.getMnemonic();
if (m != 0) {
InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW);
if (map == null) {
map = new ComponentInputMapUIResource(b);
SwingUtilities.replaceUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW, map);
}
map.clear();
map.put(KeyStroke.getKeyStroke(m, BasicLookAndFeel.getFocusAcceleratorKeyMask(), false), "pressed");
map.put(KeyStroke.getKeyStroke(m, BasicLookAndFeel.getFocusAcceleratorKeyMask(), true), "released");
map.put(KeyStroke.getKeyStroke(m, 0, true), "released");
} else {
InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW);
if (map != null) {
map.clear();
}
}
}
use of javax.swing.plaf.ComponentInputMapUIResource in project intellij-community by JetBrains.
the class ActionButtonWithText method updateMnemonic.
private void updateMnemonic(int lastMnemonic, int mnemonic) {
if (mnemonic == lastMnemonic) {
return;
}
InputMap windowInputMap = SwingUtilities.getUIInputMap(this, JComponent.WHEN_IN_FOCUSED_WINDOW);
int mask = SystemInfo.isMac ? InputEvent.ALT_MASK | InputEvent.CTRL_MASK : InputEvent.ALT_MASK;
if (lastMnemonic != 0 && windowInputMap != null) {
windowInputMap.remove(KeyStroke.getKeyStroke(lastMnemonic, mask, false));
}
if (mnemonic != 0) {
if (windowInputMap == null) {
windowInputMap = new ComponentInputMapUIResource(this);
SwingUtilities.replaceUIInputMap(this, JComponent.WHEN_IN_FOCUSED_WINDOW, windowInputMap);
}
windowInputMap.put(KeyStroke.getKeyStroke(mnemonic, mask, false), "doClick");
}
}
use of javax.swing.plaf.ComponentInputMapUIResource in project adempiere by adempiere.
the class AdempiereButtonListener method updateMnemonicBindingX.
// propertyChange
/**
* Update Mnemonic Binding
* @param b button
*/
void updateMnemonicBindingX(AbstractButton b) {
int m = b.getMnemonic();
if (m != 0) {
InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW);
if (map == null) {
map = new ComponentInputMapUIResource(b);
SwingUtilities.replaceUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW, map);
}
map.clear();
String className = b.getClass().getName();
// Default Buttons
int mask = InputEvent.ALT_MASK;
if (// In Tab
b instanceof JCheckBox || className.indexOf("VButton") != -1)
mask = InputEvent.SHIFT_MASK + InputEvent.CTRL_MASK;
map.put(KeyStroke.getKeyStroke(m, mask, false), "pressed");
map.put(KeyStroke.getKeyStroke(m, mask, true), "released");
map.put(KeyStroke.getKeyStroke(m, 0, true), "released");
} else {
InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW);
if (map != null)
map.clear();
}
}
use of javax.swing.plaf.ComponentInputMapUIResource in project adempiere by adempiere.
the class AdempiereLabelUI 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);
}
}
}
Aggregations