use of javax.swing.ActionMap in project adempiere by adempiere.
the class AdempiereTabbedPaneUI method installKeyboardActions.
protected void installKeyboardActions() {
super.installKeyboardActions();
// in the supper class, by our own.
if (scrollableTabLayoutEnabled()) {
Action forwardAction = new ScrollTabsForwardAction();
Action backwardAction = new ScrollTabsBackwardAction();
ActionMap am = SwingUtilities.getUIActionMap(tabPane);
am.put("scrollTabsForwardAction", forwardAction);
am.put("scrollTabsBackwardAction", backwardAction);
tabScroller.scrollForwardButton.setAction(forwardAction);
tabScroller.scrollBackwardButton.setAction(backwardAction);
}
}
use of javax.swing.ActionMap 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.ActionMap 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.ActionMap 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;
}
use of javax.swing.ActionMap in project jmeter by apache.
the class SearchTreePanel method init.
private void init() {
// WARNING: called from ctor so must not be overridden (i.e. must be private or final)
setLayout(new BorderLayout(10, 10));
//$NON-NLS-1$
searchTF = new JTextField(20);
InputMap im = searchTF.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(KeyStrokes.ENTER, SEARCH_TEXT_COMMAND);
ActionMap am = searchTF.getActionMap();
am.put(SEARCH_TEXT_COMMAND, new EnterAction());
//$NON-NLS-1$
isRegexpCB = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_regexp"), false);
//$NON-NLS-1$
isCaseSensitiveCB = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_case"), false);
isRegexpCB.setFont(FONT_SMALL);
isCaseSensitiveCB.setFont(FONT_SMALL);
//$NON-NLS-1$
searchButton = new JButton(JMeterUtils.getResString("search"));
searchButton.addActionListener(this);
//$NON-NLS-1$
resetButton = new JButton(JMeterUtils.getResString("reset"));
resetButton.addActionListener(this);
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
searchPanel.add(new JLabel(JMeterUtils.getResString("search_text_field")));
searchPanel.add(searchTF);
searchPanel.add(isCaseSensitiveCB);
searchPanel.add(isRegexpCB);
searchPanel.add(searchButton);
searchPanel.add(resetButton);
add(searchPanel);
}
Aggregations