use of javax.swing.InputMap 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.InputMap in project adempiere by adempiere.
the class VLookup method processKeyBinding.
// VLookup_mouseAdapter
@Override
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
if (e.getSource() == m_combo || e.getSource() == m_text || e.getSource() == this) {
return super.processKeyBinding(ks, e, condition, pressed);
}
JComponent editorComp = null;
if (m_lookup != null && m_lookup.getDisplayType() != DisplayType.Search)
editorComp = m_combo;
else
editorComp = m_text;
InputMap map = editorComp.getInputMap(condition);
ActionMap am = editorComp.getActionMap();
if (map != null && am != null && isEnabled()) {
Object binding = map.get(ks);
Action action = (binding == null) ? null : am.get(binding);
if (action != null) {
return SwingUtilities.notifyAction(action, ks, e, editorComp, e.getModifiers());
}
}
return false;
}
use of javax.swing.InputMap in project adempiere by adempiere.
the class Util method printActionInputMap.
// dump (Map)
/**
* Print Action and Input Map for component
* @param comp Component with ActionMap
*/
public static void printActionInputMap(JComponent comp) {
// Action Map
ActionMap am = comp.getActionMap();
// including Parents
Object[] amKeys = am.allKeys();
if (amKeys != null) {
System.out.println("-------------------------");
System.out.println("ActionMap for Component " + comp.toString());
for (int i = 0; i < amKeys.length; i++) {
Action a = am.get(amKeys[i]);
StringBuffer sb = new StringBuffer("- ");
sb.append(a.getValue(Action.NAME));
if (a.getValue(Action.ACTION_COMMAND_KEY) != null)
sb.append(", Cmd=").append(a.getValue(Action.ACTION_COMMAND_KEY));
if (a.getValue(Action.SHORT_DESCRIPTION) != null)
sb.append(" - ").append(a.getValue(Action.SHORT_DESCRIPTION));
System.out.println(sb.toString() + " - " + a);
}
}
/** Same as below
KeyStroke[] kStrokes = comp.getRegisteredKeyStrokes();
if (kStrokes != null)
{
System.out.println("-------------------------");
System.out.println("Registered Key Strokes - " + comp.toString());
for (int i = 0; i < kStrokes.length; i++)
{
System.out.println("- " + kStrokes[i].toString());
}
}
/** Focused */
InputMap im = comp.getInputMap(JComponent.WHEN_FOCUSED);
KeyStroke[] kStrokes = im.allKeys();
if (kStrokes != null) {
System.out.println("-------------------------");
System.out.println("InputMap for Component When Focused - " + comp.toString());
for (int i = 0; i < kStrokes.length; i++) {
System.out.println("- " + kStrokes[i].toString() + " - " + im.get(kStrokes[i]).toString());
}
}
/** Focused in Window */
im = comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
kStrokes = im.allKeys();
if (kStrokes != null) {
System.out.println("-------------------------");
System.out.println("InputMap for Component When Focused in Window - " + comp.toString());
for (int i = 0; i < kStrokes.length; i++) {
System.out.println("- " + kStrokes[i].toString() + " - " + im.get(kStrokes[i]).toString());
}
}
/** Focused when Ancester */
im = comp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
kStrokes = im.allKeys();
if (kStrokes != null) {
System.out.println("-------------------------");
System.out.println("InputMap for Component When Ancestor - " + comp.toString());
for (int i = 0; i < kStrokes.length; i++) {
System.out.println("- " + kStrokes[i].toString() + " - " + im.get(kStrokes[i]).toString());
}
}
System.out.println("-------------------------");
}
use of javax.swing.InputMap in project jmeter by apache.
the class SelectTemplatesDialog method createRootPane.
@Override
protected JRootPane createRootPane() {
JRootPane rootPane = new JRootPane();
// Hide Window on ESC
Action escapeAction = new //$NON-NLS-1$
AbstractAction(//$NON-NLS-1$
"ESCAPE") {
/**
*
*/
private static final long serialVersionUID = -6543764044868772971L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
};
// Do search on Enter
Action enterAction = new //$NON-NLS-1$
AbstractAction(//$NON-NLS-1$
"ENTER") {
private static final long serialVersionUID = -3661361497864527363L;
@Override
public void actionPerformed(final ActionEvent actionEvent) {
checkDirtyAndLoad(actionEvent);
}
};
ActionMap actionMap = rootPane.getActionMap();
actionMap.put(escapeAction.getValue(Action.NAME), escapeAction);
actionMap.put(enterAction.getValue(Action.NAME), enterAction);
InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
inputMap.put(KeyStrokes.ENTER, enterAction.getValue(Action.NAME));
return rootPane;
}
use of javax.swing.InputMap in project jmeter by apache.
the class RowDetailDialog method createRootPane.
@Override
protected JRootPane createRootPane() {
JRootPane rootPane = new JRootPane();
// Hide Window on ESC
Action escapeAction = new AbstractAction("ESCAPE") {
private static final long serialVersionUID = -8699034338969407625L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
};
// Do update on Enter
Action enterAction = new AbstractAction("ENTER") {
private static final long serialVersionUID = -1529005452976176873L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
doUpdate(actionEvent);
setVisible(false);
}
};
ActionMap actionMap = rootPane.getActionMap();
actionMap.put(escapeAction.getValue(Action.NAME), escapeAction);
actionMap.put(enterAction.getValue(Action.NAME), enterAction);
InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
inputMap.put(KeyStrokes.ENTER, enterAction.getValue(Action.NAME));
return rootPane;
}
Aggregations