Example usage for java.awt.event KeyEvent VK_J

List of usage examples for java.awt.event KeyEvent VK_J

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_J.

Prototype

int VK_J

To view the source code for java.awt.event KeyEvent VK_J.

Click Source Link

Document

Constant for the "J" key.

Usage

From source file:Main.java

/**
 * Returns the mnemonic integer./*from   w w w.  jav a  2s.c  o  m*/
 * 
 * @param c The character (uppercase)
 * @return The mnemonic.
 */
@SuppressWarnings("incomplete-switch")
private static int setMnemonicsGet(char c) {
    int mnemonic = 0;
    switch (Character.toUpperCase(c)) {
    case '0':
        mnemonic = KeyEvent.VK_0;
        break;
    case '1':
        mnemonic = KeyEvent.VK_1;
        break;
    case '2':
        mnemonic = KeyEvent.VK_2;
        break;
    case '3':
        mnemonic = KeyEvent.VK_3;
        break;
    case '4':
        mnemonic = KeyEvent.VK_4;
        break;
    case '5':
        mnemonic = KeyEvent.VK_5;
        break;
    case '6':
        mnemonic = KeyEvent.VK_6;
        break;
    case '7':
        mnemonic = KeyEvent.VK_7;
        break;
    case '8':
        mnemonic = KeyEvent.VK_8;
        break;
    case '9':
        mnemonic = KeyEvent.VK_9;
        break;
    case 'A':
        mnemonic = KeyEvent.VK_A;
        break;
    case 'B':
        mnemonic = KeyEvent.VK_B;
        break;
    case 'C':
        mnemonic = KeyEvent.VK_C;
        break;
    case 'D':
        mnemonic = KeyEvent.VK_D;
        break;
    case 'E':
        mnemonic = KeyEvent.VK_E;
        break;
    case 'F':
        mnemonic = KeyEvent.VK_F;
        break;
    case 'G':
        mnemonic = KeyEvent.VK_G;
        break;
    case 'H':
        mnemonic = KeyEvent.VK_H;
        break;
    case 'I':
        mnemonic = KeyEvent.VK_I;
        break;
    case 'J':
        mnemonic = KeyEvent.VK_J;
        break;
    case 'K':
        mnemonic = KeyEvent.VK_K;
        break;
    case 'L':
        mnemonic = KeyEvent.VK_L;
        break;
    case 'M':
        mnemonic = KeyEvent.VK_M;
        break;
    case 'N':
        mnemonic = KeyEvent.VK_N;
        break;
    case 'O':
        mnemonic = KeyEvent.VK_O;
        break;
    case 'P':
        mnemonic = KeyEvent.VK_P;
        break;
    case 'Q':
        mnemonic = KeyEvent.VK_Q;
        break;
    case 'R':
        mnemonic = KeyEvent.VK_R;
        break;
    case 'S':
        mnemonic = KeyEvent.VK_S;
        break;
    case 'T':
        mnemonic = KeyEvent.VK_T;
        break;
    case 'U':
        mnemonic = KeyEvent.VK_U;
        break;
    case 'V':
        mnemonic = KeyEvent.VK_V;
        break;
    case 'W':
        mnemonic = KeyEvent.VK_W;
        break;
    case 'X':
        mnemonic = KeyEvent.VK_X;
        break;
    case 'Y':
        mnemonic = KeyEvent.VK_Y;
        break;
    case 'Z':
        mnemonic = KeyEvent.VK_Z;
        break;
    }
    return mnemonic;
}

From source file:org.zaproxy.zap.extension.spiderAjax.SpiderPanel.java

/**
 * This method initializes this class and its attributes
 * /*from   w  ww .  ja va  2s  .  c  om*/
 */
private void initialize() {
    this.setLayout(new BorderLayout());
    if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
        this.setSize(600, 200);
    }
    this.add(getAJAXSpiderPanel(), java.awt.BorderLayout.CENTER);
    scanStatus = new ScanStatus(
            new ImageIcon(SpiderPanel.class.getResource("/resource/icon/16/spiderAjax.png")),
            this.extension.getMessages().getString("spiderajax.panel.title"));

    this.setDefaultAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | Event.SHIFT_MASK, false));
    this.setMnemonic(Constant.messages.getChar("spiderajax.panel.mnemonic"));

    if (View.isInitialised()) {
        View.getSingleton().getMainFrame().getMainFooterPanel()
                .addFooterToolbarRightLabel(scanStatus.getCountLabel());
    }

}

From source file:net.chaosserver.timelord.swingui.TimelordMenu.java

/**
 * Creates the file menu./*from   w ww.  ja  v  a  2 s.  c  om*/
 *
 * @return the new file menu
 */
protected JMenu createFileMenu() {
    JMenu fileMenu = new JMenu(resourceBundle.getString(RROOT + ".fileMenuName"));
    JMenuItem menuItem;

    fileMenu.setMnemonic(KeyEvent.VK_F);

    JMenu exportMenu = new JMenu(resourceBundle.getString(RROOT + ".file.export"));
    exportMenu.setMnemonic(KeyEvent.VK_A);

    menuItem = new JMenuItem(resourceBundle.getString(RROOT + ".file.export.jordan"), KeyEvent.VK_J);

    menuItem.setToolTipText(resourceBundle.getString(RROOT + ".file.export.jordan.tooltip"));

    menuItem.setActionCommand(ACTION_EXPORT_JORDAN);
    menuItem.addActionListener(this);
    exportMenu.add(menuItem);

    menuItem = new JMenuItem(resourceBundle.getString(RROOT + ".file.export.doug"), KeyEvent.VK_D);

    menuItem.setToolTipText("For Losers");
    menuItem.setActionCommand(ACTION_EXPORT_DOUG);
    menuItem.addActionListener(this);
    exportMenu.add(menuItem);

    exportMenu.addSeparator();
    menuItem = new JMenuItem("XML...", KeyEvent.VK_X);
    menuItem.setActionCommand(ACTION_EXPORT_XML);
    menuItem.addActionListener(this);
    exportMenu.add(menuItem);

    fileMenu.add(exportMenu);

    if (!OsUtil.isMac()) {
        fileMenu.addSeparator();
        menuItem = new JMenuItem("Exit", KeyEvent.VK_X);
        menuItem.setActionCommand(ACTION_EXIT);
        menuItem.addActionListener(this);
        fileMenu.add(menuItem);
    }

    return fileMenu;
}

From source file:org.zaproxy.zap.extension.soap.ExtensionImportWSDL.java

private ZapMenuItem getMenuImportUrlWSDL() {
    if (menuImportUrlWSDL == null) {
        menuImportUrlWSDL = new ZapMenuItem("soap.topmenu.tools.importRemoteWSDL",
                KeyStroke.getKeyStroke(KeyEvent.VK_J, Event.CTRL_MASK, false));
        menuImportUrlWSDL/*from   www .ja  v  a 2s .c o  m*/
                .setToolTipText(Constant.messages.getString("soap.topmenu.tools.importRemoteWSDL.tooltip"));

        final ExtensionImportWSDL shadowCopy = this;
        menuImportUrlWSDL.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        new ImportFromUrlDialog(View.getSingleton().getMainFrame(), shadowCopy);
                    }
                });
            }
        });
    }
    return menuImportUrlWSDL;
}

From source file:org.apache.tika.gui.TikaGUI.java

private void addMenuBar() {
    JMenuBar bar = new JMenuBar();

    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    addMenuItem(file, "Open...", "openfile", KeyEvent.VK_O);
    addMenuItem(file, "Open URL...", "openurl", KeyEvent.VK_U);
    file.addSeparator();/*  w  ww .j  av a 2  s. co m*/
    addMenuItem(file, "Exit", "exit", KeyEvent.VK_X);
    bar.add(file);

    JMenu view = new JMenu("View");
    view.setMnemonic(KeyEvent.VK_V);
    addMenuItem(view, "Metadata", "metadata", KeyEvent.VK_M);
    addMenuItem(view, "Formatted text", "html", KeyEvent.VK_F);
    addMenuItem(view, "Plain text", "text", KeyEvent.VK_P);
    addMenuItem(view, "Main content", "main", KeyEvent.VK_C);
    addMenuItem(view, "Structured text", "xhtml", KeyEvent.VK_S);
    addMenuItem(view, "Recursive JSON", "json", KeyEvent.VK_J);
    bar.add(view);

    bar.add(Box.createHorizontalGlue());
    JMenu help = new JMenu("Help");
    help.setMnemonic(KeyEvent.VK_H);
    addMenuItem(help, "About Tika", "about", KeyEvent.VK_A);
    bar.add(help);

    setJMenuBar(bar);
}

From source file:com.mirth.connect.client.ui.components.rsta.RSTAPreferences.java

private void setDefaultKeyStrokeMap() {
    keyStrokeMap = new HashMap<String, KeyStroke>();

    boolean isOSX = RTextArea.isOSX();
    int defaultModifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    int ctrl = InputEvent.CTRL_MASK;
    int alt = InputEvent.ALT_MASK;
    int shift = InputEvent.SHIFT_MASK;
    int defaultShift = defaultModifier | shift;
    int moveByWordMod = isOSX ? alt : defaultModifier;
    int moveByWordModShift = moveByWordMod | shift;

    putKeyStroke(ActionInfo.UNDO, KeyEvent.VK_Z, defaultModifier);

    if (isOSX) {//from w w  w  .java2 s. co  m
        putKeyStroke(ActionInfo.REDO, KeyEvent.VK_Z, defaultShift);
    } else {
        putKeyStroke(ActionInfo.REDO, KeyEvent.VK_Y, defaultModifier);
    }

    putKeyStroke(ActionInfo.CUT, KeyEvent.VK_X, defaultModifier);
    putKeyStroke(ActionInfo.COPY, KeyEvent.VK_C, defaultModifier);
    putKeyStroke(ActionInfo.PASTE, KeyEvent.VK_V, defaultModifier);
    putKeyStroke(ActionInfo.DELETE, KeyEvent.VK_DELETE, 0);
    putKeyStroke(ActionInfo.DELETE_REST_OF_LINE, KeyEvent.VK_DELETE, defaultModifier);
    putKeyStroke(ActionInfo.DELETE_LINE, KeyEvent.VK_D, defaultModifier);
    putKeyStroke(ActionInfo.JOIN_LINE, KeyEvent.VK_J, defaultModifier);
    putKeyStroke(ActionInfo.SELECT_ALL, KeyEvent.VK_A, defaultModifier);
    putKeyStroke(ActionInfo.FIND_REPLACE, KeyEvent.VK_F, defaultModifier);
    putKeyStroke(ActionInfo.FIND_NEXT, KeyEvent.VK_G, defaultModifier);
    putKeyStroke(ActionInfo.CLEAR_MARKED_OCCURRENCES, KeyEvent.VK_ESCAPE, 0);
    putKeyStroke(ActionInfo.FOLD_COLLAPSE, KeyEvent.VK_SUBTRACT, defaultModifier);
    putKeyStroke(ActionInfo.FOLD_EXPAND, KeyEvent.VK_ADD, defaultModifier);
    putKeyStroke(ActionInfo.FOLD_COLLAPSE_ALL, KeyEvent.VK_DIVIDE, defaultModifier);
    putKeyStroke(ActionInfo.FOLD_COLLAPSE_ALL_COMMENTS, KeyEvent.VK_DIVIDE, defaultShift);
    putKeyStroke(ActionInfo.FOLD_EXPAND_ALL, KeyEvent.VK_MULTIPLY, defaultModifier);
    putKeyStroke(ActionInfo.GO_TO_MATCHING_BRACKET, KeyEvent.VK_OPEN_BRACKET, defaultModifier);
    putKeyStroke(ActionInfo.TOGGLE_COMMENT, KeyEvent.VK_SLASH, defaultModifier);
    putKeyStroke(ActionInfo.AUTO_COMPLETE, KeyEvent.VK_SPACE, ctrl);

    if (isOSX) {
        putKeyStroke(ActionInfo.DOCUMENT_START, KeyEvent.VK_HOME, 0);
        putKeyStroke(ActionInfo.DOCUMENT_END, KeyEvent.VK_END, 0);
        putKeyStroke(ActionInfo.DOCUMENT_SELECT_START, KeyEvent.VK_HOME, shift);
        putKeyStroke(ActionInfo.DOCUMENT_SELECT_END, KeyEvent.VK_END, shift);
        putKeyStroke(ActionInfo.LINE_START, KeyEvent.VK_LEFT, defaultModifier);
        putKeyStroke(ActionInfo.LINE_END, KeyEvent.VK_RIGHT, defaultModifier);
        putKeyStroke(ActionInfo.LINE_SELECT_START, KeyEvent.VK_LEFT, defaultShift);
        putKeyStroke(ActionInfo.LINE_SELECT_END, KeyEvent.VK_RIGHT, defaultShift);
    } else {
        putKeyStroke(ActionInfo.DOCUMENT_START, KeyEvent.VK_HOME, defaultModifier);
        putKeyStroke(ActionInfo.DOCUMENT_END, KeyEvent.VK_END, defaultModifier);
        putKeyStroke(ActionInfo.DOCUMENT_SELECT_START, KeyEvent.VK_HOME, defaultShift);
        putKeyStroke(ActionInfo.DOCUMENT_SELECT_END, KeyEvent.VK_END, defaultShift);
        putKeyStroke(ActionInfo.LINE_START, KeyEvent.VK_HOME, 0);
        putKeyStroke(ActionInfo.LINE_END, KeyEvent.VK_END, 0);
        putKeyStroke(ActionInfo.LINE_SELECT_START, KeyEvent.VK_HOME, shift);
        putKeyStroke(ActionInfo.LINE_SELECT_END, KeyEvent.VK_END, shift);
    }

    putKeyStroke(ActionInfo.MOVE_LEFT, KeyEvent.VK_LEFT, 0);
    putKeyStroke(ActionInfo.MOVE_LEFT_SELECT, KeyEvent.VK_LEFT, shift);
    putKeyStroke(ActionInfo.MOVE_LEFT_WORD, KeyEvent.VK_LEFT, moveByWordMod);
    putKeyStroke(ActionInfo.MOVE_LEFT_WORD_SELECT, KeyEvent.VK_LEFT, moveByWordModShift);
    putKeyStroke(ActionInfo.MOVE_RIGHT, KeyEvent.VK_RIGHT, 0);
    putKeyStroke(ActionInfo.MOVE_RIGHT_SELECT, KeyEvent.VK_RIGHT, shift);
    putKeyStroke(ActionInfo.MOVE_RIGHT_WORD, KeyEvent.VK_RIGHT, moveByWordMod);
    putKeyStroke(ActionInfo.MOVE_RIGHT_WORD_SELECT, KeyEvent.VK_RIGHT, moveByWordModShift);
    putKeyStroke(ActionInfo.MOVE_UP, KeyEvent.VK_UP, 0);
    putKeyStroke(ActionInfo.MOVE_UP_SELECT, KeyEvent.VK_UP, shift);
    putKeyStroke(ActionInfo.MOVE_UP_SCROLL, KeyEvent.VK_UP, defaultModifier);
    putKeyStroke(ActionInfo.MOVE_UP_LINE, KeyEvent.VK_UP, alt);
    putKeyStroke(ActionInfo.MOVE_DOWN, KeyEvent.VK_DOWN, 0);
    putKeyStroke(ActionInfo.MOVE_DOWN_SELECT, KeyEvent.VK_DOWN, shift);
    putKeyStroke(ActionInfo.MOVE_DOWN_SCROLL, KeyEvent.VK_DOWN, defaultModifier);
    putKeyStroke(ActionInfo.MOVE_DOWN_LINE, KeyEvent.VK_DOWN, alt);
    putKeyStroke(ActionInfo.PAGE_UP, KeyEvent.VK_PAGE_UP, 0);
    putKeyStroke(ActionInfo.PAGE_UP_SELECT, KeyEvent.VK_PAGE_UP, shift);
    putKeyStroke(ActionInfo.PAGE_LEFT_SELECT, KeyEvent.VK_PAGE_UP, defaultShift);
    putKeyStroke(ActionInfo.PAGE_DOWN, KeyEvent.VK_PAGE_DOWN, 0);
    putKeyStroke(ActionInfo.PAGE_DOWN_SELECT, KeyEvent.VK_PAGE_DOWN, shift);
    putKeyStroke(ActionInfo.PAGE_RIGHT_SELECT, KeyEvent.VK_PAGE_DOWN, defaultShift);
    putKeyStroke(ActionInfo.INSERT_LF_BREAK, KeyEvent.VK_ENTER, 0);
    putKeyStroke(ActionInfo.INSERT_CR_BREAK, KeyEvent.VK_ENTER, shift);
    putKeyStroke(ActionInfo.MACRO_BEGIN, KeyEvent.VK_B, defaultShift);
    putKeyStroke(ActionInfo.MACRO_END, KeyEvent.VK_N, defaultShift);
    putKeyStroke(ActionInfo.MACRO_PLAYBACK, KeyEvent.VK_M, defaultShift);
}

From source file:javazoom.jlgui.player.amp.StandalonePlayer.java

/**
 * Install keyboard shortcuts./*from  w ww  . j a  va 2 s.  c  o  m*/
 */
public void setKeyBoardShortcut() {
    KeyStroke jKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_J, 0, false);
    KeyStroke ctrlPKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK, false);
    KeyStroke altSKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.ALT_MASK, false);
    KeyStroke vKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V, 0, false);
    String searchID = "TAGSEARCH";
    String preferenceID = "PREFERENCES";
    String skinbrowserID = "SKINBROWSER";
    String stopplayerID = "STOPPLAYER";
    Action searchAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (mp != null)
                mp.processJumpToFile(e.getModifiers());
        }
    };
    Action preferencesAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (mp != null)
                mp.processPreferences(e.getModifiers());
        }
    };
    Action skinbrowserAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (mp != null)
                mp.processSkinBrowser(e.getModifiers());
        }
    };
    Action stopplayerAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (mp != null)
                mp.processStop(MouseEvent.BUTTON1_MASK);
        }
    };
    setKeyboardAction(searchID, jKeyStroke, searchAction);
    setKeyboardAction(preferenceID, ctrlPKeyStroke, preferencesAction);
    setKeyboardAction(skinbrowserID, altSKeyStroke, skinbrowserAction);
    setKeyboardAction(stopplayerID, vKeyStroke, stopplayerAction);
}

From source file:ee.ioc.cs.vsle.editor.Editor.java

/**
 * Build menu./*from  w  ww .j a v a 2  s.  c o m*/
 */
public void makeMenu() {
    JMenuItem menuItem;

    JMenu menu;
    JMenu submenu;

    menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    menu = new JMenu(Menu.MENU_FILE);
    menu.setMnemonic(KeyEvent.VK_F);
    menuItem = new JMenuItem(Menu.NEW_SCHEME, KeyEvent.VK_N);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.LOAD_SCHEME, KeyEvent.VK_O);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.RELOAD_SCHEME, KeyEvent.VK_R);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.SAVE_SCHEME, KeyEvent.VK_S);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.SAVE_SCHEME_AS);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.DELETE_SCHEME, KeyEvent.VK_D);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    submenu = new JMenu(Menu.EXPORT_MENU);
    menu.add(submenu);
    //submenu.setMnemonic( KeyEvent.VK_E );

    SchemeExporter.makeSchemeExportMenu(submenu, getActionListener());

    // Export window graphics
    submenu.add(GraphicsExporter.getExportMenu());

    menu.addSeparator();
    menuItem = new JMenuItem(Menu.PRINT, KeyEvent.VK_P);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.EXIT, KeyEvent.VK_X);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuBar.add(menu);
    menu = new JMenu(Menu.MENU_EDIT);
    menu.setMnemonic(KeyEvent.VK_E);

    menu.add(undoAction);
    menu.add(redoAction);
    menu.add(cloneAction);

    menuItem = new JMenuItem(Menu.SCHEME_FIND, KeyEvent.VK_F);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK));
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.SELECT_ALL, KeyEvent.VK_A);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.CLEAR_ALL, KeyEvent.VK_C);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    final JCheckBoxMenuItem painterEnabled = new JCheckBoxMenuItem(Menu.CLASSPAINTER, true);
    painterEnabled.addActionListener(getActionListener());
    menu.add(painterEnabled);

    menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            Canvas canvas = Editor.getInstance().getCurrentCanvas();
            if (canvas == null || !canvas.getPackage().hasPainters()) {
                painterEnabled.setVisible(false);
            } else {
                painterEnabled.setVisible(true);
                painterEnabled.setSelected(canvas.isEnableClassPainter());
            }
        }

    });

    menuBar.add(menu);

    menu = new JMenu(Menu.MENU_VIEW);
    menu.setMnemonic(KeyEvent.VK_V);
    gridCheckBox = new JCheckBoxMenuItem(Menu.GRID, RuntimeProperties.isShowGrid());
    gridCheckBox.setMnemonic('G');
    gridCheckBox.addActionListener(getActionListener());
    menu.add(gridCheckBox);

    ctrlCheckBox = new JCheckBoxMenuItem(Menu.CONTROL_PANEL, RuntimeProperties.isShowControls());
    ctrlCheckBox.setMnemonic('C');
    ctrlCheckBox.addActionListener(getActionListener());
    menu.add(ctrlCheckBox);

    showPortCheckBox = new JCheckBoxMenuItem(Menu.SHOW_PORTS, true);
    showPortCheckBox.addActionListener(getActionListener());
    menu.add(showPortCheckBox);

    showObjectNamesCheckBox = new JCheckBoxMenuItem(Menu.SHOW_NAMES, false);
    showObjectNamesCheckBox.addActionListener(getActionListener());
    menu.add(showObjectNamesCheckBox);

    //sync View with current canvas
    menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            Canvas canvas;

            if ((canvas = getCurrentCanvas()) == null)
                return;

            gridCheckBox.setSelected(canvas.isGridVisible());
            ctrlCheckBox.setSelected(canvas.isCtrlPanelVisible());
            showPortCheckBox.setSelected(canvas.isDrawPorts());
            showObjectNamesCheckBox.setSelected(canvas.isShowObjectNames());
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

    });

    menuBar.add(menu);

    menu = new JMenu(Menu.MENU_PACKAGE);
    menu.setMnemonic(KeyEvent.VK_P);
    menuItem = new JMenuItem(Menu.LOAD, KeyEvent.VK_L);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.RELOAD, KeyEvent.VK_R);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.INFO, KeyEvent.VK_I);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    if (Desktop.isDesktopSupported()) {
        menuItem = new JMenuItem(Menu.BROWSE_PACKAGE, KeyEvent.VK_B);
        menuItem.addActionListener(getActionListener());
        menu.add(menuItem);
    }
    menuItem = new JMenuItem(Menu.CLOSE, KeyEvent.VK_C);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.CLOSE_ALL);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuBar.add(menu);
    menu.add(new JSeparator());
    final JMenu submenuRecent = new JMenu(Menu.RECENT);
    submenuRecent.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        final JMenuItem empty = new JMenuItem("Empty");

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {

            makeRecentSubMenu(submenuRecent);

            if (submenuRecent.getMenuComponentCount() == 0) {

                submenuRecent.add(empty);
                empty.setEnabled(false);

            } else {
                if (!((submenuRecent.getMenuComponentCount() == 1)
                        && (submenuRecent.getPopupMenu().getComponentIndex(empty) >= -1))) {
                    submenuRecent.remove(empty);
                }
            }

        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

    });
    menu.add(submenuRecent);
    final JMenu menuScheme = new JMenu(Menu.MENU_SCHEME);
    menuScheme.setMnemonic(KeyEvent.VK_S);
    makeSchemeMenu(menuScheme);

    menuScheme.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {

            makeSchemeMenu(menuScheme);

        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

    });

    /*
     * menuItem = new JMenuItem("Planner");
     * menuItem.addActionListener(aListener); menuScheme.add(menuItem);
     * menuItem = new JMenuItem("Plan, compile, run");
     * menuItem.setActionCommand("Run");
     * menuItem.addActionListener(aListener); menuScheme.add(menuItem);
     */
    // menuScheme.setMnemonic(KeyEvent.VK_A);
    menuBar.add(menuScheme);
    menu = new JMenu(Menu.MENU_OPTIONS);
    menu.setMnemonic(KeyEvent.VK_O);

    menuItem = new JMenuItem(Menu.SETTINGS, KeyEvent.VK_S);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, ActionEvent.CTRL_MASK));
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.FONTS);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.SAVE_SETTINGS);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    submenu = new JMenu(Menu.MENU_LAF);
    submenu.setMnemonic(KeyEvent.VK_L);
    Look.getInstance().createMenuItems(submenu);
    menu.add(submenu);
    menuBar.add(menu);

    makeToolsMenu(menuBar);

    menu = new JMenu(Menu.MENU_HELP);
    menu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(menu);
    menuItem = new JMenuItem(Menu.DOCS, KeyEvent.VK_D);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
}

From source file:livecanvas.mesheditor.MeshEditor.java

public JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu, subMenu;/* ww  w  .j av  a 2  s  . co m*/
    JMenuItem menuItem;
    menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_F);
    menu.add(menuItem = Utils.createMenuItem("New", NEW, KeyEvent.VK_N, "ctrl N", this));
    menu.add(menuItem = Utils.createMenuItem("Open...", OPEN, KeyEvent.VK_O, "ctrl O", this));
    menu.add(menuItem = Utils.createMenuItem("Save", SAVE, KeyEvent.VK_S, "ctrl S", this));
    menu.addSeparator();
    menu.add(menuItem = Utils.createMenuItem("Exit", EXIT, KeyEvent.VK_X, "", this));
    menuBar.add(menu);
    menu = new JMenu("Edit");
    menu.setMnemonic(KeyEvent.VK_E);
    menu.add(menuItem = Utils.createMenuItem("Undo", UNDO, KeyEvent.VK_U, "ctrl Z", this));
    menu.add(menuItem = Utils.createMenuItem("Redo", REDO, KeyEvent.VK_R, "ctrl Y", this));
    menu.addSeparator();
    menu.add(menuItem = Utils.createMenuItem("Cut", CUT, KeyEvent.VK_T, "ctrl X", this));
    menu.add(menuItem = Utils.createMenuItem("Copy", COPY, KeyEvent.VK_C, "ctrl C", this));
    menu.add(menuItem = Utils.createMenuItem("Paste", PASTE, KeyEvent.VK_P, "ctrl V", this));
    menu.addSeparator();
    menu.add(menuItem = Utils.createMenuItem("Select All", SELECT_ALL, KeyEvent.VK_A, "ctrl A", this));
    menu.add(menuItem = Utils.createMenuItem("Invert Selection", INVERT_SELECTION, 0, "", this));
    menu.addSeparator();
    menu.add(menuItem = Utils.createMenuItem("Settings...", SETTINGS, KeyEvent.VK_S, "", this));
    menuBar.add(menu);
    menu = new JMenu("Tools");
    menu.setMnemonic(KeyEvent.VK_T);
    menu.add(menuItem = Utils.createMenuItem("Brush", TOOLS_BRUSH, KeyEvent.VK_B, "B", this));
    menu.add(menuItem = Utils.createMenuItem("Pencil", TOOLS_PEN, KeyEvent.VK_N, "N", this));
    menu.add(menuItem = Utils.createMenuItem("Magic Wand", TOOLS_MAGICWAND, KeyEvent.VK_W, "W", this));
    menu.add(menuItem = Utils.createMenuItem("Set Control Points", TOOLS_SETCONTROLPOINTS, KeyEvent.VK_C, "C",
            this));
    menu.add(menuItem = Utils.createMenuItem("Pointer", TOOLS_POINTER, KeyEvent.VK_P, "P", this));
    menu.add(menuItem = Utils.createMenuItem("Pan / Zoom", TOOLS_PANZOOM, KeyEvent.VK_Z, "Z", this));
    menuBar.add(menu);
    menu = new JMenu("Layers");
    menu.setMnemonic(KeyEvent.VK_L);
    menu.add(menuItem = Utils.createMenuItem("Add Layer...", ADD_LAYER, KeyEvent.VK_A, "", this));
    menu.add(menuItem = Utils.createMenuItem("Remove", REMOVE_LAYER, KeyEvent.VK_R, "", this));
    menu.add(menuItem = Utils.createMenuItem("Duplicate", DUPLICATE_LAYER, KeyEvent.VK_C, "", this));
    menu.addSeparator();
    menu.add(menuItem = Utils.createMenuItem("Move Up", MOVEUP_LAYER, KeyEvent.VK_U, "", this));
    menu.add(menuItem = Utils.createMenuItem("Move Down", MOVEDOWN_LAYER, KeyEvent.VK_D, "", this));
    menu.addSeparator();
    menu.add(menuItem = Utils.createMenuItem("Reparent Layer...", REPARENT_LAYER, KeyEvent.VK_R, "", this));
    menu.addSeparator();
    menu.add(menuItem = Utils.createMenuItem("Group Layers", GROUP_LAYERS, KeyEvent.VK_G, "", this));
    menu.add(menuItem = Utils.createMenuItem("Ungroup Layer", UNGROUP_LAYER, KeyEvent.VK_N, "", this));
    menu.addSeparator();
    menu.add(menuItem = Utils.createMenuItem("Join Layers", JOIN_LAYERS, KeyEvent.VK_J, "", this));
    menu.add(menuItem = Utils.createMenuItem("Intersect", INTERSECT_LAYERS, KeyEvent.VK_I, "", this));
    menu.add(menuItem = Utils.createMenuItem("Subtract", SUBTRACT_LAYERS, KeyEvent.VK_S, "", this));
    menu.addSeparator();
    menu.add(menuItem = Utils.createMenuItem("Rename...", RENAME_LAYER, KeyEvent.VK_E, "", this));
    menu.addSeparator();
    subMenu = new JMenu("Background Reference");
    subMenu.add(menuItem = Utils.createMenuItem("Set...", BGREF_SET, KeyEvent.VK_S, "", this));
    subMenu.add(menuItem = Utils.createMenuItem("Remove", BGREF_REMOVE, KeyEvent.VK_R, "", this));
    menu.add(subMenu);
    menuBar.add(menu);
    menu.addSeparator();
    menu.add(menuItem = Utils.createMenuItem("Create Mesh Grid", CREATE_MESHGRID, KeyEvent.VK_M, "", this));
    menu.addSeparator();
    menu.add(menuItem = Utils.createCheckBoxMenuItem("See Through", SEE_THROUGH, KeyEvent.VK_T, "", this));
    menuItem.setSelected(true);
    menu.add(menuItem = Utils.createCheckBoxMenuItem("Show Mesh", SHOW_MESH, KeyEvent.VK_M, "", this));
    menuItem.setSelected(true);
    return menuBar;
}

From source file:userinterface.properties.GUIGraphHandler.java

private void initComponents() {
    theTabs = new JTabbedPane() {

        @Override/*ww  w .  jav  a 2s .c om*/
        public String getTitleAt(int index) {
            try {
                TabClosePanel panel = (TabClosePanel) getTabComponentAt(index);
                return panel.getTitle();
            } catch (Exception e) {
                return "";
            }
        }

        @Override
        public String getToolTipTextAt(int index) {
            return ((TabClosePanel) getTabComponentAt(index)).getToolTipText();
        }

        @Override
        public void setTitleAt(int index, String title) {

            if (((TabClosePanel) getTabComponentAt(index)) == null) {
                return;
            }

            ((TabClosePanel) getTabComponentAt(index)).setTitle(title);
        }

        @Override
        public void setIconAt(int index, Icon icon) {
            ((TabClosePanel) getTabComponentAt(index)).setIcon(icon);
        }

        @Override
        public void setToolTipTextAt(int index, String toolTipText) {
            ((TabClosePanel) getTabComponentAt(index)).setToolTip(toolTipText);
        }

    };

    theTabs.addMouseListener(this);
    theTabs.addMouseWheelListener(new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            if (e.getPreciseWheelRotation() > 0.0) {

                if (theTabs.getSelectedIndex() != (theTabs.getTabCount() - 1))
                    theTabs.setSelectedIndex(theTabs.getSelectedIndex() + 1);
            } else {

                if (theTabs.getSelectedIndex() != 0)
                    theTabs.setSelectedIndex(theTabs.getSelectedIndex() - 1);
            }
        }
    });

    setLayout(new BorderLayout());
    add(theTabs, BorderLayout.CENTER);

    graphOptions = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            GraphOptions graphOptions = options.get(theTabs.getSelectedIndex());
            graphOptions.setVisible(true);
        }
    };

    graphOptions.putValue(Action.NAME, "Graph options");
    graphOptions.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_G));
    graphOptions.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallOptions.png"));
    graphOptions.putValue(Action.LONG_DESCRIPTION, "Displays the options dialog for the graph.");

    zoomIn = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof ChartPanel)
                ((ChartPanel) mgm).zoomInBoth(-1, -1);
            else if (mgm instanceof Graph3D) {
                double rho = ((Graph3D) mgm).getChart3DPanel().getViewPoint().getRho();
                ((Graph3D) mgm).getChart3DPanel().getViewPoint().setRho(rho - 5);
                ((Graph3D) mgm).getChart3DPanel().repaint();
            }
        }
    };

    zoomIn.putValue(Action.NAME, "In");
    zoomIn.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I));
    zoomIn.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerFwd.png"));
    zoomIn.putValue(Action.LONG_DESCRIPTION, "Zoom in on the graph.");

    zoomOut = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof ChartPanel)
                ((ChartPanel) mgm).zoomOutBoth(-1, -1);
            else if (mgm instanceof Graph3D) {
                double rho = ((Graph3D) mgm).getChart3DPanel().getViewPoint().getRho();
                ((Graph3D) mgm).getChart3DPanel().getViewPoint().setRho(rho + 5);
                ((Graph3D) mgm).getChart3DPanel().repaint();
            }
        }
    };

    zoomOut.putValue(Action.NAME, "Out");
    zoomOut.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_O));
    zoomOut.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerRew.png"));
    zoomOut.putValue(Action.LONG_DESCRIPTION, "Zoom out of the graph.");

    zoomDefault = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof ChartPanel)
                ((ChartPanel) mgm).restoreAutoBounds();
            else if (mgm instanceof Graph3D) {
                ((Graph3D) mgm).getChart3DPanel().zoomToFit();
                ((Graph3D) mgm).getChart3DPanel().getDrawable()
                        .setViewPoint(new ViewPoint3D(-Math.PI / 2, Math.PI * 1.124, 70.0, 0.0));
                ((Graph3D) mgm).getChart3DPanel().repaint();

            }
        }
    };

    zoomDefault.putValue(Action.NAME, "Default");
    zoomDefault.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D));
    zoomDefault.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerStart.png"));
    zoomDefault.putValue(Action.LONG_DESCRIPTION, "Set the default zoom for the graph.");

    importXML = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (plug.showOpenFileDialog(graFilter) != JFileChooser.APPROVE_OPTION)
                return;
            try {
                Graph mgm = Graph.load(plug.getChooserFile());
                addGraph(mgm);
            } catch (GraphException ex) {
                plug.error("Could not import PRISM graph file:\n" + ex.getMessage());
            }
        }
    };
    importXML.putValue(Action.NAME, "PRISM graph (*.gra)");
    importXML.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I));
    importXML.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileGraph.png"));
    importXML.putValue(Action.LONG_DESCRIPTION, "Imports a saved PRISM graph from a file.");

    addFunction = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {

            plotNewFunction();
        }
    };
    addFunction.putValue(Action.NAME, "Plot function");
    addFunction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
    addFunction.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFunction.png"));
    addFunction.putValue(Action.LONG_DESCRIPTION, "Plots a new specified function on the current graph");

    exportXML = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (plug.showSaveFileDialog(graFilter) != JFileChooser.APPROVE_OPTION)
                return;
            Graph mgm = (Graph) models.get(theTabs.getSelectedIndex());
            try {
                mgm.save(plug.getChooserFile());
            } catch (PrismException ex) {
                plug.error("Could not export PRISM graph file:\n" + ex.getMessage());
            }
        }
    };
    exportXML.putValue(Action.NAME, "PRISM graph (*.gra)");
    exportXML.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_X));
    exportXML.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileGraph.png"));
    exportXML.putValue(Action.LONG_DESCRIPTION, "Export graph as a PRISM graph file.");

    exportImageJPG = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel model = getModel(theTabs.getSelectedIndex());

            GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), model,
                    GUIImageExportDialog.JPEG);
            saveImage(imageDialog);
        }
    };
    exportImageJPG.putValue(Action.NAME, "JPEG Interchange Format (*.jpg, *.jpeg)");
    exportImageJPG.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_J));
    exportImageJPG.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileImage.png"));
    exportImageJPG.putValue(Action.LONG_DESCRIPTION, "Export graph as a JPEG file.");

    exportImagePNG = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel model = getModel(theTabs.getSelectedIndex());
            GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), model,
                    GUIImageExportDialog.PNG);
            saveImage(imageDialog);

        }
    };
    exportImagePNG.putValue(Action.NAME, "Portable Network Graphics (*.png)");
    exportImagePNG.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
    exportImagePNG.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileImage.png"));
    exportImagePNG.putValue(Action.LONG_DESCRIPTION, "Export graph as a Portable Network Graphics file.");

    exportPDF = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (plug.showSaveFileDialog(pdfFilter) != JFileChooser.APPROVE_OPTION)
                return;

            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof ChartPanel)
                Graph.exportToPDF(plug.getChooserFile(), ((ChartPanel) mgm).getChart());
            else if (mgm instanceof Graph3D) {

                Graph3D.exportToPDF(plug.getChooserFile(), ((Graph3D) mgm).getChart3DPanel());
            }

        }
    };
    exportPDF.putValue(Action.NAME, "Portable document format (*.pdf)");
    exportPDF.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
    exportPDF.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFilePdf.png"));
    exportPDF.putValue(Action.LONG_DESCRIPTION, "Export the graph as a Portable document format file.");

    exportImageEPS = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel model = getModel(theTabs.getSelectedIndex());

            if (model instanceof ChartPanel) {

                GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), (ChartPanel) model,
                        GUIImageExportDialog.EPS);

                saveImage(imageDialog);

            }
        }
    };
    exportImageEPS.putValue(Action.NAME, "Encapsulated PostScript (*.eps)");
    exportImageEPS.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_E));
    exportImageEPS.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFilePdf.png"));
    exportImageEPS.putValue(Action.LONG_DESCRIPTION, "Export graph as an Encapsulated PostScript file.");

    exportMatlab = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (plug.showSaveFileDialog(matlabFilter) != JFileChooser.APPROVE_OPTION)
                return;

            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof Graph) {

                try {

                    ((Graph) mgm).exportToMatlab(plug.getChooserFile());

                } catch (IOException ex) {
                    plug.error("Could not export Matlab file:\n" + ex.getMessage());
                }

            } else if (mgm instanceof Graph3D) {

                try {

                    ((Graph3D) mgm).exportToMatlab(plug.getChooserFile());

                } catch (IOException e1) {

                    plug.error("Could not export Matlab file:\n" + e1.getMessage());
                    e1.printStackTrace();
                }
            }

        }
    };
    exportMatlab.putValue(Action.NAME, "Matlab file (*.m)");
    exportMatlab.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_M));
    exportMatlab.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileMatlab.png"));
    exportMatlab.putValue(Action.LONG_DESCRIPTION, "Export graph as a Matlab file.");

    exportGnuplot = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (plug.showSaveFileDialog(gnuplotFilter) != JFileChooser.APPROVE_OPTION)
                return;

            JPanel mgm = models.get(theTabs.getSelectedIndex());

            if (mgm instanceof ChartPanel) {

                try {
                    if (mgm instanceof Graph && !(mgm instanceof ParametricGraph)) {

                        ((Graph) mgm).exportToGnuplot(plug.getChooserFile());
                    } else if (mgm instanceof ParametricGraph) {

                        ((ParametricGraph) mgm).exportToGnuplot(plug.getChooserFile());
                    } else if (mgm instanceof Histogram) {
                        ((Histogram) mgm).exportToGnuplot(plug.getChooserFile());
                    }

                } catch (IOException ex) {
                    plug.error("Could not export Gnuplot file:\n" + ex.getMessage());
                }
            }

            else if (mgm instanceof Graph3D) {

                try {

                    ((Graph3D) mgm).exportToGnuplot(plug.getChooserFile());

                } catch (IOException ex) {

                    plug.error("Could not export Gnuplot file:\n" + ex.getMessage());
                    ex.printStackTrace();
                }
            }

        }
    };

    exportGnuplot.putValue(Action.NAME, "GNU Plot file(*.gnuplot)");
    exportGnuplot.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_G));
    exportGnuplot.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallgnuplot.png"));
    exportGnuplot.putValue(Action.LONG_DESCRIPTION, "Export graph as a GNU plot file.");

    printGraph = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel graph = models.get(theTabs.getSelectedIndex());

            if (graph instanceof ChartPanel) {

                if (graph instanceof Graph) {

                    if (!((Graph) graph).getDisplaySettings().getBackgroundColor().equals(Color.white)) {
                        if (plug.questionYesNo(
                                "Your graph has a coloured background, this background will show up on the \n"
                                        + "printout. Would you like to make the current background colour white?") == 0) {

                            ((Graph) graph).getDisplaySettings().setBackgroundColor(Color.white);
                        }
                    }

                } else if (graph instanceof Histogram) {

                    if (!((Histogram) graph).getDisplaySettings().getBackgroundColor().equals(Color.white)) {
                        if (plug.questionYesNo(
                                "Your graph has a coloured background, this background will show up on the \n"
                                        + "printout. Would you like to make the current background colour white?") == 0) {
                            ((Histogram) graph).getDisplaySettings().setBackgroundColor(Color.white);
                        }
                    }

                }

                ((ChartPanel) graph).createChartPrintJob();
            }

            if (graph instanceof Graph3D) {

                ((Graph3D) graph).createPrintJob();
            }
        }
    };

    printGraph.putValue(Action.NAME, "Print graph");
    printGraph.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P));
    printGraph.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPrint.png"));
    printGraph.putValue(Action.LONG_DESCRIPTION, "Print the graph to a printer or file");

    deleteGraph = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JPanel graph = models.get(theTabs.getSelectedIndex());

            models.remove(theTabs.getSelectedIndex());
            options.remove(theTabs.getSelectedIndex());
            theTabs.remove(graph);
        }
    };
    deleteGraph.putValue(Action.NAME, "Delete graph");
    deleteGraph.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D));
    deleteGraph.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallDelete.png"));
    deleteGraph.putValue(Action.LONG_DESCRIPTION, "Deletes the graph.");

    zoomMenu = new JMenu("Zoom");
    zoomMenu.setMnemonic('Z');
    zoomMenu.setIcon(GUIPrism.getIconFromImage("smallView.png"));
    zoomMenu.add(zoomIn);
    zoomMenu.add(zoomOut);
    zoomMenu.add(zoomDefault);

    exportMenu = new JMenu("Export graph");
    exportMenu.setMnemonic('E');
    exportMenu.setIcon(GUIPrism.getIconFromImage("smallExport.png"));
    exportMenu.add(exportXML);
    exportMenu.add(exportImagePNG);
    exportMenu.add(exportPDF);
    exportMenu.add(exportImageEPS);
    exportMenu.add(exportImageJPG);

    exportMenu.add(exportMatlab);
    exportMenu.add(exportGnuplot);

    importMenu = new JMenu("Import graph");
    importMenu.setMnemonic('I');
    importMenu.setIcon(GUIPrism.getIconFromImage("smallImport.png"));
    importMenu.add(importXML);

    graphMenu.add(graphOptions);
    graphMenu.add(zoomMenu);
    graphMenu.addSeparator();
    graphMenu.add(printGraph);
    graphMenu.add(deleteGraph);
    graphMenu.addSeparator();
    graphMenu.add(exportMenu);
    graphMenu.add(importMenu);
    graphMenu.add(addFunction);

    /* Tab context menu */
    backMenu.add(importXML);
}