Search in sources :

Example 51 with AbstractAction

use of javax.swing.AbstractAction in project JMRI by JMRI.

the class LocoIcon method showPopUp.

/**
     * Pop-up only if right click and not dragged
     */
@Override
public boolean showPopUp(JPopupMenu popup) {
    if (_entry != null) {
        popup.add(new AbstractAction("Throttle") {

            @Override
            public void actionPerformed(ActionEvent e) {
                tf = jmri.jmrit.throttle.ThrottleFrameManager.instance().createThrottleFrame();
                tf.getAddressPanel().setRosterEntry(_entry);
                tf.toFront();
            }
        });
    }
    popup.add(makeLocoIconMenu());
    if (isEditable()) {
        getEditor().setShowAlignmentMenu(this, popup);
        getEditor().setShowCoordinatesMenu(this, popup);
        popup.add(makeDockingMenu());
        popup.add(makeDockMenu());
        getPopupUtility().setTextFontMenu(popup);
    } else {
        setRotateMenu(popup);
        if (_entry == null) {
            setTextEditMenu(popup);
        }
        popup.add(makeDockMenu());
        getPopupUtility().setTextFontMenu(popup);
        getEditor().setRemoveMenu(this, popup);
    }
    return true;
}
Also used : ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction)

Example 52 with AbstractAction

use of javax.swing.AbstractAction in project processdash by dtuma.

the class LOCDiffDialog method setupWindowKeyBindings.

private void setupWindowKeyBindings(JComponent c) {
    InputMap inputMap = c.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "closeDialog");
    c.getActionMap().put("closeDialog", new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            closeDialog();
        }
    });
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "doCount");
    c.getActionMap().put("doCount", new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            doCount();
        }
    });
}
Also used : ActionEvent(java.awt.event.ActionEvent) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Example 53 with AbstractAction

use of javax.swing.AbstractAction in project processdash by dtuma.

the class UserEditor method makeToolbar.

private Component makeToolbar(boolean editable) {
    FilterHandler filterer = EventHandler.create(FilterHandler.class, this, "updateFilter");
    BoxUtils toolbar = BoxUtils.hbox();
    searchField = new JTextField(10);
    searchField.getDocument().addDocumentListener(filterer);
    toolbar.addItems(resources.getString("Find") + ":", 3, searchField, 20);
    showInactiveCheckbox = new JCheckBox(resources.getString("Show_Inactive"));
    showInactiveCheckbox.addActionListener(filterer);
    if (isLegacyPdesMode()) {
        showInactiveCheckbox.setSelected(true);
    } else {
        toolbar.addItem(showInactiveCheckbox);
    }
    toolbar.addItems(100, BoxUtils.GLUE);
    if (editable) {
        AbstractAction add = (//
        PersonLookupDialog.isLookupServerConfigured() ? new AddPdesUserAction() : new AddPlainUserAction());
        toolbar.addItems(5, new JButton(add));
    }
    toolbar.addItems(5, new JButton(new ViewAction()));
    if (editable)
        toolbar.addItems(5, new JButton(new DeleteAction()));
    toolbar.addItem(new JOptionPaneTweaker.MakeResizable());
    toolbar.addItem(new JOptionPaneTweaker.DisableKeys());
    return toolbar;
}
Also used : JOptionPaneTweaker(net.sourceforge.processdash.ui.lib.JOptionPaneTweaker) JButton(javax.swing.JButton) BoxUtils(net.sourceforge.processdash.ui.lib.BoxUtils) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) AbstractAction(javax.swing.AbstractAction)

Example 54 with AbstractAction

use of javax.swing.AbstractAction in project processdash by dtuma.

the class MacGUIUtils method tweakTable.

public static void tweakTable(JTable table) {
    if (isMacOSX()) {
        table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_META, KeyEvent.META_DOWN_MASK), "doNothing");
        table.getActionMap().put("doNothing", new AbstractAction() {

            public void actionPerformed(ActionEvent e) {
            }
        });
    }
}
Also used : ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction)

Example 55 with AbstractAction

use of javax.swing.AbstractAction in project JMRI by JMRI.

the class PanelProPane method statusPanel.

@Override
protected JPanel statusPanel() {
    JPanel j = new JPanel();
    j.setLayout(new BoxLayout(j, BoxLayout.Y_AXIS));
    j.add(super.statusPanel());
    // Buttons
    Action quit = new AbstractAction(Bundle.getMessage("MenuItemQuit")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            Apps.handleQuit();
        }
    };
    JPanel p3 = new JPanel();
    p3.setLayout(new java.awt.FlowLayout());
    JButton h1 = new JButton(Bundle.getMessage("ButtonHelp"));
    jmri.util.HelpUtil.addHelpToComponent(h1, "html.apps.PanelPro.PanelPro");
    h1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    p3.add(h1);
    JButton q1 = new JButton(Bundle.getMessage("ButtonQuit"));
    q1.addActionListener(quit);
    q1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    p3.add(q1);
    j.add(p3);
    return j;
}
Also used : JPanel(javax.swing.JPanel) AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) AbstractAction(javax.swing.AbstractAction)

Aggregations

AbstractAction (javax.swing.AbstractAction)174 ActionEvent (java.awt.event.ActionEvent)162 Action (javax.swing.Action)42 InputMap (javax.swing.InputMap)34 JButton (javax.swing.JButton)33 JMenu (javax.swing.JMenu)30 JPanel (javax.swing.JPanel)30 ActionListener (java.awt.event.ActionListener)24 JMenuItem (javax.swing.JMenuItem)24 ActionMap (javax.swing.ActionMap)23 JScrollPane (javax.swing.JScrollPane)16 JPopupMenu (javax.swing.JPopupMenu)15 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)14 BorderLayout (java.awt.BorderLayout)14 BoxLayout (javax.swing.BoxLayout)12 JSeparator (javax.swing.JSeparator)12 JDialog (javax.swing.JDialog)11 WindowEvent (java.awt.event.WindowEvent)9 JMenuBar (javax.swing.JMenuBar)9 JTextField (javax.swing.JTextField)9