use of javax.swing.ActionMap in project binnavi by google.
the class CDatabaseSettingsPanel method setupHotkeys.
/**
* Sets up the hotkeys of the panel.
*/
private void setupHotkeys() {
final InputMap inputMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
final ActionMap actionMap = getActionMap();
inputMap.put(HotKeys.DATABASE_SETTINGS_TEST_CONNECTION_KEY.getKeyStroke(), "TEST_CONNECTION");
actionMap.put("TEST_CONNECTION", new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent event) {
if (testButton.isEnabled()) {
testConnection();
}
}
});
inputMap.put(HotKeys.DATABASE_SETTINGS_SAVE_CONNECTION_KEY.getKeyStroke(), "SAVE_CONNECTION");
actionMap.put("SAVE_CONNECTION", new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent event) {
saveConnection();
}
});
}
use of javax.swing.ActionMap in project binnavi by google.
the class CGraphSearchField method registerHotkeys.
/**
* Registers all hotkeys processed by the graph search field.
*/
private void registerHotkeys() {
final ActionMap actionMap = ((JTextField) getEditor().getEditorComponent()).getActionMap();
final InputMap imap = ((JTextField) getEditor().getEditorComponent()).getInputMap();
setActionMap(actionMap);
setInputMap(JComponent.WHEN_FOCUSED, imap);
imap.put(HotKeys.GRAPH_SEARCH_NEXT_KEY.getKeyStroke(), "NEXT");
imap.put(HotKeys.GRAPH_SEARCH_NEXT_ZOOM_KEY.getKeyStroke(), "NEXT_ZOOM");
imap.put(HotKeys.GRAPH_SEARCH_PREVIOUS_KEY.getKeyStroke(), "PREVIOUS");
imap.put(HotKeys.GRAPH_SEARCH_PREVIOUS_ZOOM_KEY.getKeyStroke(), "PREVIOUS_ZOOM");
actionMap.put("NEXT", CActionProxy.proxy(new CActionHotKey("NEXT")));
actionMap.put("NEXT_ZOOM", CActionProxy.proxy(new CActionHotKey("NEXT_ZOOM")));
actionMap.put("PREVIOUS", CActionProxy.proxy(new CActionHotKey("PREVIOUS")));
actionMap.put("PREVIOUS_ZOOM", CActionProxy.proxy(new CActionHotKey("PREVIOUS_ZOOM")));
}
use of javax.swing.ActionMap in project groovy-core by groovy.
the class ConsoleTextEditor method initActions.
protected void initActions() {
ActionMap map = getActionMap();
PrintAction printAction = new PrintAction();
map.put(StructuredSyntaxResources.PRINT, printAction);
}
use of javax.swing.ActionMap in project smile by haifengl.
the class FontChooser method createDialog.
private JDialog createDialog(Component parent) {
Frame frame = parent instanceof Frame ? (Frame) parent : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
JDialog dialog = new JDialog(frame, getMessage("SelectFont"), true);
Action okAction = new DialogOKAction(dialog);
Action cancelAction = new DialogCancelAction(dialog);
JButton okButton = new JButton(okAction);
okButton.setFont(DEFAULT_FONT);
JButton cancelButton = new JButton(cancelAction);
cancelButton.setFont(DEFAULT_FONT);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setLayout(new GridLayout(2, 1));
buttonsPanel.add(okButton);
buttonsPanel.add(cancelButton);
buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));
ActionMap actionMap = buttonsPanel.getActionMap();
actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));
JPanel dialogEastPanel = new JPanel();
dialogEastPanel.setLayout(new BorderLayout());
dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);
dialog.getContentPane().add(this, BorderLayout.CENTER);
dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
dialog.pack();
dialog.setLocationRelativeTo(frame);
return dialog;
}
use of javax.swing.ActionMap in project jdk8u_jdk by JetBrains.
the class BasicLookAndFeel method getAudioActionMap.
// ********* Auditory Cue support methods and objects *********
// also see the "AuditoryCues" section of the defaults table
/**
* Returns an <code>ActionMap</code> containing the audio actions
* for this look and feel.
* <P>
* The returned <code>ActionMap</code> contains <code>Actions</code> that
* embody the ability to render an auditory cue. These auditory
* cues map onto user and system activities that may be useful
* for an end user to know about (such as a dialog box appearing).
* <P>
* At the appropriate time,
* the {@code ComponentUI} is responsible for obtaining an
* <code>Action</code> out of the <code>ActionMap</code> and passing
* it to <code>playSound</code>.
* <P>
* This method first looks up the {@code ActionMap} from the
* defaults using the key {@code "AuditoryCues.actionMap"}.
* <p>
* If the value is {@code non-null}, it is returned. If the value
* of the default {@code "AuditoryCues.actionMap"} is {@code null}
* and the value of the default {@code "AuditoryCues.cueList"} is
* {@code non-null}, an {@code ActionMapUIResource} is created and
* populated. Population is done by iterating over each of the
* elements of the {@code "AuditoryCues.cueList"} array, and
* invoking {@code createAudioAction()} to create an {@code
* Action} for each element. The resulting {@code Action} is
* placed in the {@code ActionMapUIResource}, using the array
* element as the key. For example, if the {@code
* "AuditoryCues.cueList"} array contains a single-element, {@code
* "audioKey"}, the {@code ActionMapUIResource} is created, then
* populated by way of {@code actionMap.put(cueList[0],
* createAudioAction(cueList[0]))}.
* <p>
* If the value of the default {@code "AuditoryCues.actionMap"} is
* {@code null} and the value of the default
* {@code "AuditoryCues.cueList"} is {@code null}, an empty
* {@code ActionMapUIResource} is created.
*
*
* @return an ActionMap containing {@code Actions}
* responsible for playing auditory cues
* @throws ClassCastException if the value of the
* default {@code "AuditoryCues.actionMap"} is not an
* {@code ActionMap}, or the value of the default
* {@code "AuditoryCues.cueList"} is not an {@code Object[]}
* @see #createAudioAction
* @see #playSound(Action)
* @since 1.4
*/
protected ActionMap getAudioActionMap() {
ActionMap audioActionMap = (ActionMap) UIManager.get("AuditoryCues.actionMap");
if (audioActionMap == null) {
Object[] acList = (Object[]) UIManager.get("AuditoryCues.cueList");
if (acList != null) {
audioActionMap = new ActionMapUIResource();
for (int counter = acList.length - 1; counter >= 0; counter--) {
audioActionMap.put(acList[counter], createAudioAction(acList[counter]));
}
}
UIManager.getLookAndFeelDefaults().put("AuditoryCues.actionMap", audioActionMap);
}
return audioActionMap;
}
Aggregations