use of javax.swing.ActionMap 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);
}
}
}
use of javax.swing.ActionMap in project adempiere by adempiere.
the class VTreePanel method setMappings.
private void setMappings(JTree tree) {
ActionMap map = tree.getActionMap();
map.put(TransferHandler.getCutAction().getValue(Action.NAME), TransferHandler.getCutAction());
map.put(TransferHandler.getPasteAction().getValue(Action.NAME), TransferHandler.getPasteAction());
}
use of javax.swing.ActionMap in project adempiere by adempiere.
the class ADempiereAutoCompleteDecorator method decorate.
/**
* Decorates a given text component for automatic completion using the
* given AutoCompleteDocument and AbstractAutoCompleteAdaptor.
*
*
* @param textComponent a text component that should be decorated
* @param document the AutoCompleteDocument to be installed on the text component
* @param adaptor the AbstractAutoCompleteAdaptor to be used
*/
public static void decorate(JTextComponent textComponent, AutoCompleteDocument document, final AbstractAutoCompleteAdaptor adaptor) {
// install the document on the text component
textComponent.setDocument(document);
// mark entire text when the text component gains focus
// otherwise the last mark would have been retained which is quiet confusing
textComponent.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
JTextComponent textComponent = (JTextComponent) e.getSource();
adaptor.markEntireText();
}
});
// Tweak some key bindings
InputMap editorInputMap = textComponent.getInputMap();
if (document.isStrictMatching()) {
// move the selection to the left on VK_BACK_SPACE
editorInputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_BACK_SPACE, 0), DefaultEditorKit.selectionBackwardAction);
// ignore VK_DELETE and CTRL+VK_X and beep instead when strict matching
editorInputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, 0), errorFeedbackAction);
editorInputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_DOWN_MASK), errorFeedbackAction);
} else {
ActionMap editorActionMap = textComponent.getActionMap();
// leave VK_DELETE and CTRL+VK_X as is
// VK_BACKSPACE will move the selection to the left if the selected item is in the list
// it will delete the previous character otherwise
editorInputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_BACK_SPACE, 0), "nonstrict-backspace");
editorActionMap.put("nonstrict-backspace", new NonStrictBackspaceAction(editorActionMap.get(DefaultEditorKit.deletePrevCharAction), editorActionMap.get(DefaultEditorKit.selectionBackwardAction), adaptor));
editorInputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_TAB, java.awt.event.KeyEvent.CTRL_DOWN_MASK), "NextMatchAction");
editorActionMap.put("NextMatchAction", new NextMatchAction(textComponent, document, adaptor));
}
}
use of javax.swing.ActionMap 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.ActionMap in project jmeter by apache.
the class SearchTreeDialog method createRootPane.
@Override
protected JRootPane createRootPane() {
JRootPane rootPane = new JRootPane();
// Hide Window on ESC
Action escapeAction = new AbstractAction("ESCAPE") {
private static final long serialVersionUID = -6543764044868772971L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
};
// Do search on Enter
Action enterAction = new AbstractAction("ENTER") {
private static final long serialVersionUID = -3661361497864527363L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
doSearch(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;
}
Aggregations