use of javax.swing.InputMap 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;
}
use of javax.swing.InputMap in project jmeter by apache.
the class EscapeDialog method createRootPane.
@Override
protected JRootPane createRootPane() {
JRootPane rootPane = new JRootPane();
Action escapeAction = new AbstractAction("ESCAPE") {
/**
*
*/
private static final long serialVersionUID = 2208129319916921772L;
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
};
InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
rootPane.getActionMap().put(escapeAction.getValue(Action.NAME), escapeAction);
return rootPane;
}
use of javax.swing.InputMap in project jmeter by apache.
the class FunctionHelper method createRootPane.
/**
* Allow Dialog to be closed by ESC key
*/
@Override
protected JRootPane createRootPane() {
JRootPane rootPane = new JRootPane();
javax.swing.Action escapeAction = new AbstractAction("ESCAPE") {
private static final long serialVersionUID = -4036804004190858925L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
};
rootPane.getActionMap().put(escapeAction.getValue(Action.NAME), escapeAction);
InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
return rootPane;
}
use of javax.swing.InputMap in project jmeter by apache.
the class SearchTextExtension method createSearchTextPanel.
/**
* Create the text find task pane
*
* @return Text find task pane
*/
private JPanel createSearchTextPanel() {
// Search field
searchPanel = new JPanel();
searchPanel.setLayout(new BoxLayout(searchPanel, BoxLayout.X_AXIS));
searchPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
// $NON-NLS-1$
label = new JLabel(JMeterUtils.getResString("search_text_field"));
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
searchPanel.add(label);
// $NON-NLS-1$
textToFindField = new JTextField();
searchPanel.add(textToFindField);
searchPanel.add(Box.createRigidArea(new Dimension(5, 0)));
// add listener to intercept texttofind changes and reset search
textToFindField.getDocument().addDocumentListener(this);
// Buttons
findButton = new JButton(JMeterUtils.getResString(// $NON-NLS-1$
"search_text_button_find"));
findButton.setFont(FONT_SMALL);
findButton.setActionCommand(SEARCH_TEXT_COMMAND);
findButton.addActionListener(this);
searchPanel.add(findButton);
// checkboxes
caseChkBox = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_case"), // $NON-NLS-1$
false);
caseChkBox.setFont(FONT_SMALL);
searchPanel.add(caseChkBox);
regexpChkBox = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_regexp"), // $NON-NLS-1$
false);
regexpChkBox.setFont(FONT_SMALL);
searchPanel.add(regexpChkBox);
// when Enter is pressed, search start
InputMap im = textToFindField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(KeyStrokes.ENTER, SEARCH_TEXT_COMMAND);
ActionMap am = textToFindField.getActionMap();
am.put(SEARCH_TEXT_COMMAND, new EnterAction());
// default not visible
searchPanel.setVisible(true);
return searchPanel;
}
use of javax.swing.InputMap in project processdash by dtuma.
the class WBSTabPanel method installKeyboardShortcuts.
/**
* Configure a number of keyboard shortcuts for navigating within the
* contents of the WBS tab panel
*/
private void installKeyboardShortcuts() {
InputMap inputMap = dataTable.getInputMap();
ActionMap actionMap = dataTable.getActionMap();
inputMap.put(KeyStroke.getKeyStroke("HOME"), "focusTree");
inputMap.put(KeyStroke.getKeyStroke("shift SPACE"), "focusTree");
actionMap.put("focusTree", new TransferFocusToWbsNode());
new MoveLeftFromDataCell().install(dataTable);
inputMap = wbsTable.getInputMap();
actionMap = wbsTable.getActionMap();
inputMap.put(KeyStroke.getKeyStroke("END"), "lastDataCol");
actionMap.put("lastDataCol", new TransferFocusToDataTable(true));
inputMap.put(KeyStroke.getKeyStroke("RIGHT"), "firstDataCol");
actionMap.put("firstDataCol", new TransferFocusToDataTable(false));
inputMap.put(KeyStroke.getKeyStroke("LEFT"), "startEditing");
inputMap = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(//
KeyStroke.getKeyStroke(//
KeyEvent.VK_T, MacGUIUtils.getCtrlModifier()), "focusTabs");
this.getActionMap().put("focusTabs", new TransferFocusToTabs());
}
Aggregations