Search in sources :

Example 1 with ActionMap

use of javax.swing.ActionMap in project groovy by apache.

the class ConsoleTextEditor method initActions.

protected void initActions() {
    ActionMap map = getActionMap();
    PrintAction printAction = new PrintAction();
    map.put(StructuredSyntaxResources.PRINT, printAction);
}
Also used : ActionMap(javax.swing.ActionMap)

Example 2 with ActionMap

use of javax.swing.ActionMap in project smile by haifengl.

the class PlotCanvas method createPropertyDialog.

/**
     * Creates the property dialog.
     * @return the property dialog.
     */
private JDialog createPropertyDialog() {
    Frame frame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, this);
    JDialog dialog = new JDialog(frame, "Plot Properties", true);
    Action okAction = new PropertyDialogOKAction(dialog);
    Action cancelAction = new PropertyDialogCancelAction(dialog);
    JButton okButton = new JButton(okAction);
    JButton cancelButton = new JButton(cancelAction);
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    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));
    String[] columnNames = { "Property", "Value" };
    if (base.dimension == 2) {
        Object[][] data = { { "Title", title }, { "Title Font", titleFont }, { "Title Color", titleColor }, { "X Axis Title", getAxis(0).getAxisLabel() }, { "X Axis Range", new double[] { base.getLowerBounds()[0], base.getUpperBounds()[0] } }, { "Y Axis Title", getAxis(1).getAxisLabel() }, { "Y Axis Range", new double[] { base.getLowerBounds()[1], base.getUpperBounds()[1] } } };
        propertyTable = new Table(data, columnNames);
    } else {
        Object[][] data = { { "Title", title }, { "Title Font", titleFont }, { "Title Color", titleColor }, { "X Axis Title", getAxis(0).getAxisLabel() }, { "X Axis Range", new double[] { base.getLowerBounds()[0], base.getUpperBounds()[0] } }, { "Y Axis Title", getAxis(1).getAxisLabel() }, { "Y Axis Range", new double[] { base.getLowerBounds()[1], base.getUpperBounds()[1] } }, { "Z Axis Title", getAxis(2).getAxisLabel() }, { "Z Axis Range", new double[] { base.getLowerBounds()[2], base.getUpperBounds()[2] } } };
        propertyTable = new Table(data, columnNames);
    }
    // There is a known issue with JTables whereby the changes made in a
    // cell editor are not committed when focus is lost.
    // This can result in the table staying in 'edit mode' with the stale
    // value in the cell being edited still showing, although the change
    // has not actually been committed to the model.
    //
    // In fact what should happen is for the method stopCellEditing()
    // on CellEditor to be called when focus is lost.
    // So the editor can choose whether to accept the new value and stop
    // editing, or have the editing cancelled without committing.
    // There is a magic property which you have to set on the JTable
    // instance to turn this feature on.
    propertyTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    propertyTable.setFillsViewportHeight(true);
    JScrollPane tablePanel = new JScrollPane(propertyTable);
    dialog.getContentPane().add(tablePanel, BorderLayout.CENTER);
    dialog.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
    dialog.pack();
    dialog.setLocationRelativeTo(frame);
    return dialog;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Frame(java.awt.Frame) AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) FlowLayout(java.awt.FlowLayout) JTable(javax.swing.JTable) Table(smile.swing.Table) ActionMap(javax.swing.ActionMap) JButton(javax.swing.JButton) InputMap(javax.swing.InputMap) JDialog(javax.swing.JDialog)

Example 3 with ActionMap

use of javax.swing.ActionMap in project binnavi by google.

the class JHexView method initHotkeys.

/**
   * Initializes the keys that can be used by the user inside the component.
   */
private void initHotkeys() {
    // Don't change focus on TAB
    setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, new HashSet<KeyStroke>());
    final InputMap inputMap = this.getInputMap();
    final ActionMap actionMap = getActionMap();
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "LEFT");
    actionMap.put("LEFT", m_leftAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.SHIFT_DOWN_MASK), "shift LEFT");
    actionMap.put("shift LEFT", m_leftAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "RIGHT");
    actionMap.put("RIGHT", m_rightAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.SHIFT_DOWN_MASK), "shift RIGHT");
    actionMap.put("shift RIGHT", m_rightAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "UP");
    actionMap.put("UP", m_upAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_DOWN_MASK), "shift UP");
    actionMap.put("shift UP", m_upAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "DOWN");
    actionMap.put("DOWN", m_downAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.SHIFT_DOWN_MASK), "shift DOWN");
    actionMap.put("shift DOWN", m_downAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "PAGE_DOWN");
    actionMap.put("PAGE_DOWN", m_pageDownAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, InputEvent.SHIFT_DOWN_MASK), "shift PAGE_DOWN");
    actionMap.put("shift PAGE_DOWN", m_pageDownAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "PAGE_UP");
    actionMap.put("PAGE_UP", m_pageUpAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.SHIFT_DOWN_MASK), "shift PAGE_UP");
    actionMap.put("shift PAGE_UP", m_pageUpAction);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "TAB");
    actionMap.put("TAB", m_tabAction);
}
Also used : ActionMap(javax.swing.ActionMap) KeyStroke(javax.swing.KeyStroke) InputMap(javax.swing.InputMap)

Example 4 with ActionMap

use of javax.swing.ActionMap in project binnavi by google.

the class CRegisterHotKeys method unregisterActions.

public static <NodeType extends ZyGraphNode<?>> void unregisterActions(final AbstractZyGraph<NodeType, ?> graph) {
    final ActionMap amap1 = graph.getView().getCanvasComponent().getActionMap();
    final ActionMap amap2 = graph.getView().getActionMap();
    amap1.remove("F2");
    amap1.remove("DOWN");
    amap1.remove("UP");
    amap1.remove("LEFT");
    amap1.remove("RIGHT");
    amap1.remove("+");
    amap1.remove("-");
    amap1.remove("m");
    amap1.remove("s");
    amap1.remove("<");
    amap1.remove("SELECT_VISIBLE_NODES");
    amap1.remove("COPY_CONTENT_FROM_SELECTED_NODES");
    amap2.remove("DOWN");
    amap2.remove("UP");
    amap2.remove("LEFT");
    amap2.remove("RIGHT");
    amap2.remove("+");
    amap2.remove("-");
    amap2.remove("m");
    amap2.remove("s");
    amap2.remove("<");
    amap2.remove("SELECT_VISIBLE_NODES");
    amap2.remove("COPY_CONTENT_FROM_SELECTED_NODES");
}
Also used : ActionMap(javax.swing.ActionMap)

Example 5 with ActionMap

use of javax.swing.ActionMap 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;
}
Also used : Action(javax.swing.Action) ActionMap(javax.swing.ActionMap) JComponent(javax.swing.JComponent) InputMap(javax.swing.InputMap)

Aggregations

ActionMap (javax.swing.ActionMap)45 InputMap (javax.swing.InputMap)38 AbstractAction (javax.swing.AbstractAction)24 ActionEvent (java.awt.event.ActionEvent)20 Action (javax.swing.Action)14 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 JButton (javax.swing.JButton)11 BorderLayout (java.awt.BorderLayout)9 JDialog (javax.swing.JDialog)8 JPanel (javax.swing.JPanel)8 JScrollPane (javax.swing.JScrollPane)7 JComponent (javax.swing.JComponent)6 JTextField (javax.swing.JTextField)6 FormBuilder (com.jgoodies.forms.builder.FormBuilder)5 FormLayout (com.jgoodies.forms.layout.FormLayout)5 Component (java.awt.Component)3 Insets (java.awt.Insets)3 List (java.util.List)3 JCheckBox (javax.swing.JCheckBox)3 FlowLayout (java.awt.FlowLayout)2