Search in sources :

Example 96 with AbstractAction

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

the class ControlPanelEditor method makeMarkerMenu.

protected void makeMarkerMenu() {
    _markerMenu = new JMenu(Bundle.getMessage("MenuMarker"));
    _menuBar.add(_markerMenu);
    _markerMenu.add(new AbstractAction(Bundle.getMessage("AddLoco")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            locoMarkerFromInput();
        }
    });
    _markerMenu.add(new AbstractAction(Bundle.getMessage("AddLocoRoster")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            locoMarkerFromRoster();
        }
    });
    _markerMenu.add(new AbstractAction(Bundle.getMessage("RemoveMarkers")) {

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

Example 97 with AbstractAction

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

the class TrackSegment method showBezierPopUp.

/**
     * Display popup menu for information and editing.
     */
protected void showBezierPopUp(MouseEvent e, int hitPointType) {
    int bezierControlPointIndex = hitPointType - BEZIER_CONTROL_POINT_OFFSET_MIN;
    if (popup != null) {
        popup.removeAll();
    } else {
        popup = new JPopupMenu();
    }
    JMenuItem jmi = popup.add(rb.getString("BezierControlPoint") + " #" + bezierControlPointIndex);
    jmi.setEnabled(false);
    popup.add(new JSeparator(JSeparator.HORIZONTAL));
    if (bezierControlPoints.size() < BEZIER_CONTROL_POINT_OFFSET_MAX - BEZIER_CONTROL_POINT_OFFSET_MIN) {
        popup.add(new AbstractAction(rb.getString("AddBezierControlPointAfter")) {

            @Override
            public void actionPerformed(ActionEvent e) {
                addBezierControlPointAfter(bezierControlPointIndex);
            }
        });
        popup.add(new AbstractAction(rb.getString("AddBezierControlPointBefore")) {

            @Override
            public void actionPerformed(ActionEvent e) {
                addBezierControlPointBefore(bezierControlPointIndex);
            }
        });
    }
    if (bezierControlPoints.size() > 2) {
        popup.add(new AbstractAction(rb.getString("DeleteBezierControlPoint") + " #" + bezierControlPointIndex) {

            @Override
            public void actionPerformed(ActionEvent e) {
                deleteBezierControlPoint(bezierControlPointIndex);
            }
        });
    }
    popup.show(e.getComponent(), e.getX(), e.getY());
}
Also used : ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator)

Example 98 with AbstractAction

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

the class PanelEditor method makeFrame.

/**
     * Create sequence of panels, etc, for layout: JFrame contains its
     * ContentPane which contains a JPanel with BoxLayout (p1) which contains a
     * JScollPane (js) which contains the targetPane
     *
     */
public JmriJFrame makeFrame(String name) {
    JmriJFrame targetFrame = new JmriJFrame(name);
    targetFrame.setVisible(false);
    JMenuBar menuBar = new JMenuBar();
    JMenu editMenu = new JMenu(Bundle.getMessage("MenuEdit"));
    menuBar.add(editMenu);
    editMenu.add(new AbstractAction(Bundle.getMessage("OpenEditor")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(true);
        }
    });
    editMenu.addSeparator();
    editMenu.add(new AbstractAction(Bundle.getMessage("DeletePanel")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (deletePanel()) {
                dispose(true);
            }
        }
    });
    targetFrame.setJMenuBar(menuBar);
    // add maker menu
    JMenu markerMenu = new JMenu(Bundle.getMessage("MenuMarker"));
    menuBar.add(markerMenu);
    markerMenu.add(new AbstractAction(Bundle.getMessage("AddLoco")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            locoMarkerFromInput();
        }
    });
    markerMenu.add(new AbstractAction(Bundle.getMessage("AddLocoRoster")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            locoMarkerFromRoster();
        }
    });
    markerMenu.add(new AbstractAction(Bundle.getMessage("RemoveMarkers")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            removeMarkers();
        }
    });
    JMenu warrantMenu = jmri.jmrit.logix.WarrantTableAction.makeWarrantMenu(isEditable());
    if (warrantMenu != null) {
        menuBar.add(warrantMenu);
    }
    targetFrame.addHelpMenu("package.jmri.jmrit.display.PanelTarget", true);
    return targetFrame;
}
Also used : JmriJFrame(jmri.util.JmriJFrame) ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 99 with AbstractAction

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

the class AppsLaunchFrame method editMenu.

protected void editMenu(JMenuBar menuBar, WindowInterface wi) {
    JMenu editMenu = new JMenu(Bundle.getMessage("MenuEdit"));
    menuBar.add(editMenu);
    // cut, copy, paste
    AbstractAction a;
    a = new DefaultEditorKit.CutAction();
    a.putValue(Action.NAME, Bundle.getMessage("MenuItemCut"));
    editMenu.add(a);
    a = new DefaultEditorKit.CopyAction();
    a.putValue(Action.NAME, Bundle.getMessage("MenuItemCopy"));
    editMenu.add(a);
    a = new DefaultEditorKit.PasteAction();
    a.putValue(Action.NAME, Bundle.getMessage("MenuItemPaste"));
    editMenu.add(a);
    // prefs
    prefsAction = new apps.gui3.TabbedPreferencesAction(Bundle.getMessage("MenuItemPreferences"));
    // Put prefs in Apple's prefered area on Mac OS X
    if (SystemType.isMacOSX()) {
        Application.getApplication().setPreferencesHandler(new PreferencesHandler() {

            @Override
            public void handlePreferences(EventObject eo) {
                prefsAction.actionPerformed(null);
            }
        });
    }
    // Include prefs in Edit menu if not on Mac OS X or not using Aqua Look and Feel
    if (!SystemType.isMacOSX() || !UIManager.getLookAndFeel().isNativeLookAndFeel()) {
        editMenu.addSeparator();
        editMenu.add(prefsAction);
    }
}
Also used : DefaultEditorKit(javax.swing.text.DefaultEditorKit) PreferencesHandler(jmri.plaf.macosx.PreferencesHandler) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu) EventObject(java.util.EventObject)

Example 100 with AbstractAction

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

the class Apps method editMenu.

protected void editMenu(JMenuBar menuBar, WindowInterface wi) {
    JMenu editMenu = new JMenu(Bundle.getMessage("MenuEdit"));
    menuBar.add(editMenu);
    // cut, copy, paste
    AbstractAction a;
    a = new DefaultEditorKit.CutAction();
    a.putValue(Action.NAME, Bundle.getMessage("MenuItemCut"));
    editMenu.add(a);
    a = new DefaultEditorKit.CopyAction();
    a.putValue(Action.NAME, Bundle.getMessage("MenuItemCopy"));
    editMenu.add(a);
    a = new DefaultEditorKit.PasteAction();
    a.putValue(Action.NAME, Bundle.getMessage("MenuItemPaste"));
    editMenu.add(a);
    // prefs
    prefsAction = new apps.gui3.TabbedPreferencesAction(Bundle.getMessage("MenuItemPreferences"));
    // Put prefs in Apple's prefered area on Mac OS X
    if (SystemType.isMacOSX()) {
        Application.getApplication().setPreferencesHandler(new PreferencesHandler() {

            @Override
            public void handlePreferences(EventObject eo) {
                doPreferences();
            }
        });
    }
    // Include prefs in Edit menu if not on Mac OS X or not using Aqua Look and Feel
    if (!SystemType.isMacOSX() || !UIManager.getLookAndFeel().isNativeLookAndFeel()) {
        editMenu.addSeparator();
        editMenu.add(prefsAction);
    }
}
Also used : DefaultEditorKit(javax.swing.text.DefaultEditorKit) PreferencesHandler(jmri.plaf.macosx.PreferencesHandler) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu) EventObject(java.util.EventObject)

Aggregations

AbstractAction (javax.swing.AbstractAction)155 ActionEvent (java.awt.event.ActionEvent)143 Action (javax.swing.Action)35 JButton (javax.swing.JButton)33 JPanel (javax.swing.JPanel)30 InputMap (javax.swing.InputMap)29 JMenu (javax.swing.JMenu)29 JMenuItem (javax.swing.JMenuItem)23 ActionListener (java.awt.event.ActionListener)21 ActionMap (javax.swing.ActionMap)20 JScrollPane (javax.swing.JScrollPane)16 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)14 BorderLayout (java.awt.BorderLayout)14 JPopupMenu (javax.swing.JPopupMenu)14 BoxLayout (javax.swing.BoxLayout)12 JSeparator (javax.swing.JSeparator)12 JDialog (javax.swing.JDialog)11 JMenuBar (javax.swing.JMenuBar)9 Dimension (java.awt.Dimension)8 WindowEvent (java.awt.event.WindowEvent)8