Example usage for java.awt.event KeyEvent VK_E

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

Introduction

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

Prototype

int VK_E

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

Click Source Link

Document

Constant for the "E" key.

Usage

From source file:edu.harvard.mcz.imagecapture.SpecimenPartAttributeDialog.java

private void init() {
    thisDialog = this;
    setBounds(100, 100, 820, 335);// ww w . j  ava 2  s .co  m
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    JPanel panel = new JPanel();
    panel.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, }));
    {
        JLabel lblAttributeType = new JLabel("Attribute Type");
        panel.add(lblAttributeType, "2, 2, right, default");
    }
    {
        comboBoxType = new JComboBox();
        comboBoxType.setModel(new DefaultComboBoxModel(
                new String[] { "caste", "scientific name", "sex", "life stage", "part association" }));
        comboBoxType.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                String item = comboBoxType.getSelectedItem().toString();
                if (item != null) {
                    comboBoxValue.setEditable(false);
                    if (item.equals("scientific name")) {
                        comboBoxValue.setEditable(true);
                    }
                    if (item.equals("sex")) {
                        comboBoxValue.setModel(new DefaultComboBoxModel(Sex.getSexValues()));
                    }
                    if (item.equals("life stage")) {
                        comboBoxValue.setModel(new DefaultComboBoxModel(LifeStage.getLifeStageValues()));
                    }
                    if (item.equals("caste")) {
                        comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues()));
                    }
                    if (item.equals("part association")) {
                        comboBoxValue
                                .setModel(new DefaultComboBoxModel(PartAssociation.getPartAssociationValues()));
                    }
                }
            }

        });
        panel.add(comboBoxType, "4, 2, fill, default");
    }
    {
        JLabel lblValue = new JLabel("Value");
        panel.add(lblValue, "2, 4, right, default");
    }
    {
        comboBoxValue = new JComboBox();
        comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues()));

        panel.add(comboBoxValue, "4, 4, fill, default");
    }
    {
        JLabel lblUnits = new JLabel("Units");
        panel.add(lblUnits, "2, 6, right, default");
    }
    {
        textFieldUnits = new JTextField();
        panel.add(textFieldUnits, "4, 6, fill, default");
        textFieldUnits.setColumns(10);
    }
    {
        JLabel lblRemarks = new JLabel("Remarks");
        panel.add(lblRemarks, "2, 8, right, default");
    }
    contentPanel.setLayout(new BorderLayout(0, 0));
    contentPanel.add(panel, BorderLayout.WEST);
    {
        textFieldRemarks = new JTextField();
        panel.add(textFieldRemarks, "4, 8, fill, default");
        textFieldRemarks.setColumns(10);
    }
    {
        JButton btnAdd = new JButton("Add");
        btnAdd.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                SpecimenPartAttribute newAttribs = new SpecimenPartAttribute();
                newAttribs.setAttributeType(comboBoxType.getSelectedItem().toString());
                newAttribs.setAttributeValue(comboBoxValue.getSelectedItem().toString());
                newAttribs.setAttributeUnits(textFieldUnits.getText());
                newAttribs.setAttributeRemark(textFieldRemarks.getText());
                newAttribs.setSpecimenPartId(parentPart);
                newAttribs.setAttributeDeterminer(Singleton.getSingletonInstance().getUserFullName());
                parentPart.getAttributeCollection().add(newAttribs);
                SpecimenPartAttributeLifeCycle sls = new SpecimenPartAttributeLifeCycle();
                try {
                    sls.attachDirty(newAttribs);
                } catch (SaveFailedException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                ((AbstractTableModel) table.getModel()).fireTableDataChanged();
            }
        });
        panel.add(btnAdd, "4, 10");
    }
    try {
        JLabel lblNewLabel = new JLabel(parentPart.getSpecimenId().getBarcode() + ":" + parentPart.getPartName()
                + " " + parentPart.getPreserveMethod() + " (" + parentPart.getLotCount()
                + ")    Right click on table to edit attributes.");
        contentPanel.add(lblNewLabel, BorderLayout.NORTH);
    } catch (Exception e) {
        JLabel lblNewLabel = new JLabel("No Specimen");
        contentPanel.add(lblNewLabel, BorderLayout.NORTH);
    }
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("caste");
    JComboBox comboBox1 = new JComboBox();
    for (int i = 0; i < Caste.getCasteValues().length; i++) {
        comboBox1.addItem(Caste.getCasteValues()[i]);
    }
    JScrollPane scrollPane = new JScrollPane();

    table = new JTable(new SpecimenPartsAttrTableModel(
            (Collection<SpecimenPartAttribute>) parentPart.getAttributeCollection()));

    //table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(comboBox));   

    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                clickedOnRow = ((JTable) e.getComponent()).getSelectedRow();
                popupMenu.show(e.getComponent(), e.getX(), e.getY());
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                clickedOnRow = ((JTable) e.getComponent()).getSelectedRow();
                popupMenu.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });

    popupMenu = new JPopupMenu();

    JMenuItem mntmCloneRow = new JMenuItem("Edit Row");
    mntmCloneRow.setMnemonic(KeyEvent.VK_E);
    mntmCloneRow.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                // Launch a dialog to edit the selected row.
                SpecimenPartAttribEditDialog popup = new SpecimenPartAttribEditDialog(
                        ((SpecimenPartsAttrTableModel) table.getModel()).getRowObject(clickedOnRow));
                popup.setVisible(true);
            } catch (Exception ex) {
                log.error(ex.getMessage());
                JOptionPane.showMessageDialog(thisDialog,
                        "Failed to edit a part attribute row. " + ex.getMessage());
            }
        }
    });
    popupMenu.add(mntmCloneRow);

    JMenuItem mntmDeleteRow = new JMenuItem("Delete Row");
    mntmDeleteRow.setMnemonic(KeyEvent.VK_D);
    mntmDeleteRow.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                if (clickedOnRow >= 0) {
                    ((SpecimenPartsAttrTableModel) table.getModel()).deleteRow(clickedOnRow);
                }
            } catch (Exception ex) {
                log.error(ex.getMessage());
                JOptionPane.showMessageDialog(thisDialog,
                        "Failed to delete a part attribute row. " + ex.getMessage());
            }
        }
    });
    popupMenu.add(mntmDeleteRow);

    // TODO: Enable controlled value editing of selected row.

    // table.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(comboBox1));

    scrollPane.setViewportView(table);
    contentPanel.add(scrollPane, BorderLayout.EAST);
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            okButton = new JButton("OK");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    okButton.grabFocus();
                    thisDialog.setVisible(false);
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    thisDialog.setVisible(false);
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
}

From source file:livecanvas.mesheditor.MeshEditor.java

public JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu, subMenu;/*w  w w .ja  v  a  2s.  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:org.photovault.swingui.PhotoCollectionThumbView.java

void createUI() {
    photoTransferHandler = new PhotoCollectionTransferHandler(this);
    setTransferHandler(photoTransferHandler);

    setAutoscrolls(true);/*from   w w  w  . j  ava  2 s.  co  m*/

    addMouseListener(this);
    addMouseMotionListener(this);

    // Create the popup menu
    popup = new JPopupMenu();
    ImageIcon propsIcon = getIcon("view_properties.png");
    editSelectionPropsAction = new EditSelectionPropsAction(this, "Properties...", propsIcon,
            "Edit properties of the selected photos", KeyEvent.VK_P);
    JMenuItem propsItem = new JMenuItem(editSelectionPropsAction);
    ImageIcon colorsIcon = getIcon("colors.png");
    editSelectionColorsAction = new EditSelectionColorsAction(this, null, "Adjust colors...", colorsIcon,
            "Adjust colors of the selected photos", KeyEvent.VK_A);
    JMenuItem colorsItem = new JMenuItem(editSelectionColorsAction);
    ImageIcon showIcon = getIcon("show_new_window.png");
    showSelectedPhotoAction = new ShowSelectedPhotoAction(this, "Show image", showIcon,
            "Show the selected phot(s)", KeyEvent.VK_S);
    JMenuItem showItem = new JMenuItem(showSelectedPhotoAction);
    showHistoryAction = new ShowPhotoHistoryAction(this, "Show history", null, "Show history of selected photo",
            KeyEvent.VK_H, null);
    resolveConflictsAction = new ResolvePhotoConflictsAction(this, "Resolve conflicts", null,
            "Resolve synchronization conflicts", KeyEvent.VK_R, null);
    JMenuItem rotateCW = new JMenuItem(ctrl.getActionAdapter("rotate_cw"));
    JMenuItem rotateCCW = new JMenuItem(ctrl.getActionAdapter("rotate_ccw"));
    JMenuItem rotate180deg = new JMenuItem(ctrl.getActionAdapter("rotate_180"));

    JMenuItem addToFolder = new JMenuItem("Add to folder...");
    addToFolder.addActionListener(this);
    addToFolder.setActionCommand(PHOTO_ADD_TO_FOLDER_CMD);
    addToFolder.setIcon(getIcon("empty_icon.png"));
    ImageIcon exportIcon = getIcon("filesave.png");
    exportSelectedAction = new ExportSelectedAction(this, "Export selected...", exportIcon,
            "Export the selected photos to from archive database to image files", KeyEvent.VK_E);
    JMenuItem exportSelected = new JMenuItem(exportSelectedAction);

    ImageIcon deleteSelectedIcon = getIcon("delete_image.png");
    deleteSelectedAction = new DeletePhotoAction(this, "Delete", deleteSelectedIcon,
            "Delete selected photos including all of their instances", KeyEvent.VK_D);
    JMenuItem deleteSelected = new JMenuItem(deleteSelectedAction);

    starIcon = getIcon("star_normal_border.png");
    rejectedIcon = getIcon("quality_unusable.png");

    rawIcon = getIcon("raw_icon.png");

    JMenuItem showHistory = new JMenuItem(showHistoryAction);
    JMenuItem resolveConflicts = new JMenuItem(resolveConflictsAction);
    AddTagAction addTagAction = new AddTagAction(ctrl, "Add tag...", null, "Add tag to image", KeyEvent.VK_T);
    JMenuItem addTag = new JMenuItem(addTagAction);
    popup.add(showItem);
    popup.add(propsItem);
    popup.add(colorsItem);
    popup.add(rotateCW);
    popup.add(rotateCCW);
    popup.add(rotate180deg);
    popup.add(addToFolder);
    popup.add(exportSelected);
    popup.add(deleteSelected);
    popup.add(showHistory);
    popup.add(resolveConflicts);
    popup.add(addTag);
    MouseListener popupListener = new PopupListener();
    addMouseListener(popupListener);

    ImageIcon selectNextIcon = getIcon("next.png");
    selectNextAction = new ChangeSelectionAction(this, ChangeSelectionAction.MOVE_FWD, "Next photo",
            selectNextIcon, "Move to next photo", KeyEvent.VK_N,
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

    ImageIcon selectPrevIcon = getIcon("previous.png");
    selectPrevAction = new ChangeSelectionAction(this, ChangeSelectionAction.MOVE_BACK, "Previous photo",
            selectPrevIcon, "Move to previous photo", KeyEvent.VK_P,
            KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

    creatingThumbIcon = getIcon("creating_thumb.png");
}

From source file:com.googlecode.bpmn_simulator.gui.BPMNSimulatorFrame.java

private JMenu createMenuFile() {
    final JMenu menuFile = new JMenu(Messages.getString("Menu.file")); //$NON-NLS-1$

    final JMenuItem menuFileOpen = new JMenuItem(Messages.getString("Menu.fileOpen")); //$NON-NLS-1$
    menuFileOpen.setMnemonic(KeyEvent.VK_O);
    menuFileOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.ALT_MASK));
    menuFileOpen.addActionListener(new ActionListener() {
        @Override//www . j  a va 2  s  . c o m
        public void actionPerformed(final ActionEvent e) {
            openFile();
        }
    });
    menuFile.add(menuFileOpen);
    menuFile.add(menuFileRecent);

    final JMenuItem menuFileReload = new JMenuItem(Messages.getString("Menu.fileReload")); //$NON-NLS-1$
    menuFileReload.setMnemonic(KeyEvent.VK_R);
    menuFileReload.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_MASK));
    menuFileReload.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            reloadDefinition();
        }
    });
    menuFile.add(menuFileReload);

    final JMenuItem menuFileClose = new JMenuItem(Messages.getString("Menu.fileClose")); //$NON-NLS-1$
    menuFileClose.setMnemonic(KeyEvent.VK_C);
    menuFileClose.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK));
    menuFileClose.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            closeSource();
        }
    });
    menuFile.add(menuFileClose);

    menuFile.addSeparator();

    final JMenuItem menuFileProperties = new JMenuItem(Messages.getString("Menu.properties")); //$NON-NLS-1$
    menuFileProperties.setMnemonic(KeyEvent.VK_P);
    menuFileProperties.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.ALT_MASK));
    menuFileProperties.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            showPropertiesDialog();
        }
    });
    menuFile.add(menuFileProperties);

    menuFile.addSeparator();

    final JMenuItem menuFileExport = createMenuFileExport();
    menuFile.add(menuFileExport);

    menuFile.addSeparator();

    final JMenuItem menuFilePreferences = new JMenuItem(Messages.getString("Menu.preferences")); //$NON-NLS-1$
    menuFilePreferences.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            showPreferencesDialog();
        }
    });
    menuFile.add(menuFilePreferences);

    menuFile.addSeparator();

    final JMenuItem menuFileExit = new JMenuItem(Messages.getString("Menu.exit")); //$NON-NLS-1$
    menuFileExit.setMnemonic(KeyEvent.VK_E);
    menuFileExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK));
    menuFileExit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            for (Frame frame : getFrames()) {
                if (frame.isActive()) {
                    frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
                }
            }
        }
    });
    menuFile.add(menuFileExit);

    menuFile.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(final MenuEvent e) {
            menuFileReload.setEnabled(isSourceOpen() && currentSource.canReopen());
            menuFileClose.setEnabled(isSourceOpen());
            menuFileProperties.setEnabled(isDefinitionOpen());
            menuFileExport.setEnabled(isDefinitionOpen());
        }

        @Override
        public void menuDeselected(final MenuEvent e) {
        }

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });

    return menuFile;
}

From source file:org.jcurl.demo.tactics.TacticsApp.java

private JMenuBar createMenu() {
    final JMenuBar bar = new JMenuBar();
    {//from   w ww. j  a v  a  2s  . c om
        final JMenu menu = bar.add(new JMenu("File"));
        menu.setMnemonic('F');
        menu.add(this.newMI("New", null, 'N', -1, this, "cmdNew"));
        menu.add(this.newMI("Open", null, 'O', KeyEvent.VK_O, this, "cmdOpen"));
        menu.addSeparator();
        menu.add(this.newMI("Export Png", null, 'P', KeyEvent.VK_E, this, "cmdExportPng"));
        menu.addSeparator();
        menu.add(this.newMI("Save", null, 'S', KeyEvent.VK_S, this, "cmdSave"));
        menu.add(this.newMI("Save As", null, 'A', -1, this, "cmdSaveAs"));
        menu.addSeparator();
        menu.add(this.newMI("Exit", null, 'x', -1, this, "cmdExit"));
    }
    {
        final JMenu menu = bar.add(new JMenu("View"));
        menu.setMnemonic('V');
        menu.add(this.newMI("Zoom", null, 'z', -1, this, "cmdZoom"));
    }
    {
        final JMenu menu = bar.add(new JMenu("Play"));
        menu.setMnemonic('P');
        menu.setEnabled(false);
        // menu.add(newMI('a', -1, bStart.getAction()));
        // menu.add(newMI('P', -1, bPause.getAction()));
        // menu.add(newMI('o', -1, bStop.getAction()));
    }
    {
        final JMenu menu = bar.add(new JMenu("Help"));
        menu.setMnemonic('H');
        menu.add(this.newMI("About", null, 'a', -1, this, "cmdAbout"));
    }
    return bar;
}

From source file:org.rdv.ui.MainPanel.java

private void initActions() {
    fileAction = new DataViewerAction("File", "File Menu", KeyEvent.VK_F);

    connectAction = new DataViewerAction("Connect", "Connect to RBNB server", KeyEvent.VK_C,
            KeyStroke.getKeyStroke(KeyEvent.VK_C, menuShortcutKeyMask | ActionEvent.SHIFT_MASK)) {
        /** serialization version identifier */
        private static final long serialVersionUID = 5038790506859429244L;

        public void actionPerformed(ActionEvent ae) {
            if (rbnbConnectionDialog == null) {
                rbnbConnectionDialog = new RBNBConnectionDialog(frame, rbnb, dataPanelManager);
            } else {
                rbnbConnectionDialog.setVisible(true);
            }/*  ww w.  j  av  a 2 s  .  c  o m*/
        }
    };

    disconnectAction = new DataViewerAction("Disconnect", "Disconnect from RBNB server", KeyEvent.VK_D,
            KeyStroke.getKeyStroke(KeyEvent.VK_D, menuShortcutKeyMask | ActionEvent.SHIFT_MASK)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -1871076535376405181L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelManager.closeAllDataPanels();
            rbnb.disconnect();
        }
    };

    loginAction = new DataViewerAction("Login", "Login as a NEES user") {
        /** serialization version identifier */
        private static final long serialVersionUID = 6105503896620555072L;

        public void actionPerformed(ActionEvent ae) {
            if (loginDialog == null) {
                loginDialog = new LoginDialog(frame);
            } else {
                loginDialog.setVisible(true);
            }
        }
    };

    logoutAction = new DataViewerAction("Logout", "Logout as a NEES user") {
        /** serialization version identifier */
        private static final long serialVersionUID = -2517567766044673777L;

        public void actionPerformed(ActionEvent ae) {
            AuthenticationManager.getInstance().setAuthentication(null);
        }
    };

    loadAction = new DataViewerAction("Load Setup", "Load data viewer setup from file") {
        /** serialization version identifier */
        private static final long serialVersionUID = 7197815395398039821L;

        public void actionPerformed(ActionEvent ae) {
            File configFile = UIUtilities.getFile(new RDVConfigurationFileFilter(), "Load");
            if (configFile != null) {
                try {
                    URL configURL = configFile.toURI().toURL();
                    ConfigurationManager.loadConfiguration(configURL);
                } catch (MalformedURLException e) {
                    DataViewer.alertError("\"" + configFile + "\" is not a valid configuration file URL.");
                }
            }
        }
    };

    saveAction = new DataViewerAction("Save Setup", "Save data viewer setup to file") {
        /** serialization version identifier */
        private static final long serialVersionUID = -8259994975940624038L;

        public void actionPerformed(ActionEvent ae) {
            File file = UIUtilities.saveFile(new RDVConfigurationFileFilter());
            if (file != null) {
                if (file.getName().indexOf(".") == -1) {
                    file = new File(file.getAbsolutePath() + ".rdv");
                }

                // prompt for overwrite if file already exists
                if (file.exists()) {
                    int overwriteReturn = JOptionPane.showConfirmDialog(null,
                            file.getName() + " already exists. Do you want to overwrite it?", "Overwrite file?",
                            JOptionPane.YES_NO_OPTION);
                    if (overwriteReturn == JOptionPane.NO_OPTION) {
                        return;
                    }
                }

                ConfigurationManager.saveConfiguration(file);
            }
        }
    };

    importAction = new DataViewerAction("Import", "Import Menu", KeyEvent.VK_I, "icons/import.gif");

    exportAction = new DataViewerAction("Export", "Export Menu", KeyEvent.VK_E, "icons/export.gif");

    exportVideoAction = new DataViewerAction("Export video channels",
            "Export video on the server to the local computer") {
        /** serialization version identifier */
        private static final long serialVersionUID = -6420430928972633313L;

        public void actionPerformed(ActionEvent ae) {
            showExportVideoDialog();
        }
    };

    exitAction = new DataViewerAction("Exit", "Exit RDV", KeyEvent.VK_X) {
        /** serialization version identifier */
        private static final long serialVersionUID = 3137490972014710133L;

        public void actionPerformed(ActionEvent ae) {
            Application.getInstance().exit(ae);
        }
    };

    controlAction = new DataViewerAction("Control", "Control Menu", KeyEvent.VK_C);

    realTimeAction = new DataViewerAction("Real Time", "View data in real time", KeyEvent.VK_R,
            KeyStroke.getKeyStroke(KeyEvent.VK_R, menuShortcutKeyMask), "icons/rt.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -7564783609370910512L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.monitor();
        }
    };

    playAction = new DataViewerAction("Play", "Playback data", KeyEvent.VK_P,
            KeyStroke.getKeyStroke(KeyEvent.VK_P, menuShortcutKeyMask), "icons/play.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 5974457444931142938L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.play();
        }
    };

    pauseAction = new DataViewerAction("Pause", "Pause data display", KeyEvent.VK_A,
            KeyStroke.getKeyStroke(KeyEvent.VK_S, menuShortcutKeyMask), "icons/pause.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -5297742186923194460L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.pause();
        }
    };

    beginningAction = new DataViewerAction("Go to beginning", "Move the location to the start of the data",
            KeyEvent.VK_B, KeyStroke.getKeyStroke(KeyEvent.VK_B, menuShortcutKeyMask), "icons/begin.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 9171304956895497898L;

        public void actionPerformed(ActionEvent ae) {
            controlPanel.setLocationBegin();
        }
    };

    endAction = new DataViewerAction("Go to end", "Move the location to the end of the data", KeyEvent.VK_E,
            KeyStroke.getKeyStroke(KeyEvent.VK_E, menuShortcutKeyMask), "icons/end.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 1798579248452726211L;

        public void actionPerformed(ActionEvent ae) {
            controlPanel.setLocationEnd();
        }
    };

    gotoTimeAction = new DataViewerAction("Go to time", "Move the location to specific date time of the data",
            KeyEvent.VK_T, KeyStroke.getKeyStroke(KeyEvent.VK_T, menuShortcutKeyMask)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6411442297488926326L;

        public void actionPerformed(ActionEvent ae) {
            TimeRange timeRange = RBNBHelper.getChannelsTimeRange();
            double time = DateTimeDialog.showDialog(frame, rbnb.getLocation(), timeRange.start, timeRange.end);
            if (time >= 0) {
                rbnb.setLocation(time);
            }
        }
    };

    updateChannelListAction = new DataViewerAction("Update Channel List", "Update the channel list",
            KeyEvent.VK_U, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), "icons/refresh.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -170096772973697277L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.updateMetadata();
        }
    };

    dropDataAction = new DataViewerAction("Drop Data", "Drop data if plaback can't keep up with data rate",
            KeyEvent.VK_D, "icons/drop_data.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 7079791364881120134L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            rbnb.dropData(menuItem.isSelected());
        }
    };

    viewAction = new DataViewerAction("View", "View Menu", KeyEvent.VK_V);

    showChannelListAction = new DataViewerAction("Show Channels", "", KeyEvent.VK_L, "icons/channels.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 4982129759386009112L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            channelListPanel.setVisible(menuItem.isSelected());
            layoutSplitPane();
            leftPanel.resetToPreferredSizes();
        }
    };

    showMetadataPanelAction = new DataViewerAction("Show Properties", "", KeyEvent.VK_P,
            "icons/properties.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 430106771704397810L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            metadataPanel.setVisible(menuItem.isSelected());
            layoutSplitPane();
            leftPanel.resetToPreferredSizes();
        }
    };

    showControlPanelAction = new DataViewerAction("Show Control Panel", "", KeyEvent.VK_C,
            "icons/control.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 6401715717710735485L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            controlPanel.setVisible(menuItem.isSelected());
        }
    };

    showAudioPlayerPanelAction = new DataViewerAction("Show Audio Player", "", KeyEvent.VK_A,
            "icons/audio.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -4248275698973916287L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            audioPlayerPanel.setVisible(menuItem.isSelected());
        }
    };

    showMarkerPanelAction = new DataViewerAction("Show Marker Panel", "", KeyEvent.VK_M, "icons/info.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -5253555511660929640L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            markerSubmitPanel.setVisible(menuItem.isSelected());
        }
    };

    dataPanelAction = new DataViewerAction("Arrange", "Arrange Data Panel Orientation", KeyEvent.VK_D);

    dataPanelHorizontalLayoutAction = new DataViewerAction("Horizontal Data Panel Orientation", "", -1,
            "icons/vertical.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 3356151813557187908L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelContainer.setLayout(DataPanelContainer.VERTICAL_LAYOUT);
        }
    };

    dataPanelVerticalLayoutAction = new DataViewerAction("Vertical Data Panel Orientation", "", -1,
            "icons/horizontal.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -4629920180285927138L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelContainer.setLayout(DataPanelContainer.HORIZONTAL_LAYOUT);
        }
    };

    showHiddenChannelsAction = new DataViewerAction("Show Hidden Channels", "", KeyEvent.VK_H,
            KeyStroke.getKeyStroke(KeyEvent.VK_H, menuShortcutKeyMask), "icons/hidden.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -2723464261568074033L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            boolean selected = menuItem.isSelected();
            channelListPanel.showHiddenChannels(selected);
        }
    };

    hideEmptyTimeAction = new DataViewerAction("Hide time with no data", "", KeyEvent.VK_D) {
        /** serialization version identifier */
        private static final long serialVersionUID = -3123608144249355642L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            boolean selected = menuItem.isSelected();
            controlPanel.hideEmptyTime(selected);
        }
    };

    fullScreenAction = new DataViewerAction("Full Screen", "", KeyEvent.VK_F,
            KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6882310862616235602L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            if (menuItem.isSelected()) {
                if (enterFullScreenMode()) {
                    menuItem.setSelected(true);
                } else {
                    menuItem.setSelected(false);
                }
            } else {
                leaveFullScreenMode();
                menuItem.setSelected(false);
            }
        }
    };

    windowAction = new DataViewerAction("Window", "Window Menu", KeyEvent.VK_W);

    closeAllDataPanelsAction = new DataViewerAction("Close all data panels", "", KeyEvent.VK_C,
            "icons/closeall.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -8104876009869238037L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelManager.closeAllDataPanels();
        }
    };

    helpAction = new DataViewerAction("Help", "Help Menu", KeyEvent.VK_H);

    usersGuideAction = new DataViewerAction("RDV Help", "Open the RDV User's Guide", KeyEvent.VK_H,
            KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -2837190869008153291L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL usersGuideURL = new URL("http://it.nees.org/library/telepresence/rdv-19-users-guide.php");
                DataViewer.browse(usersGuideURL);
            } catch (Exception e) {
            }
        }
    };

    supportAction = new DataViewerAction("RDV Support", "Get support from NEESit", KeyEvent.VK_S) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6855670513381679226L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL supportURL = new URL("http://it.nees.org/support/");
                DataViewer.browse(supportURL);
            } catch (Exception e) {
            }
        }
    };

    releaseNotesAction = new DataViewerAction("Release Notes", "Open the RDV Release Notes", KeyEvent.VK_R) {
        /** serialization version identifier */
        private static final long serialVersionUID = 7223639998298692494L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL releaseNotesURL = new URL("http://it.nees.org/library/rdv/rdv-release-notes.php");
                DataViewer.browse(releaseNotesURL);
            } catch (Exception e) {
            }
        }
    };

    aboutAction = new DataViewerAction("About RDV", "", KeyEvent.VK_A) {
        /** serialization version identifier */
        private static final long serialVersionUID = 3978467903181198979L;

        public void actionPerformed(ActionEvent ae) {
            showAboutDialog();
        }
    };

}

From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java

private JPanel getElementos() {
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING));
    panel.setOpaque(false);/*from  ww w  . ja  v a2 s  .  c o  m*/
    panel.setBorder(new TitledBorder("Elementos a Consultar"));

    JLabel jLabel = new JLabel("Recursos", SwingConstants.RIGHT);
    jLabel.setPreferredSize(ConsultaHistoricos.DIMENSION_LABEL);
    panel.add(jLabel);
    recursos = new JList(new DefaultListModel());
    recursos.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK), "selectAll");
    recursos.getActionMap().put("selectAll", new AbstractAction() {

        private static final long serialVersionUID = -5515338515763292526L;

        @Override
        public void actionPerformed(ActionEvent e) {
            recursos.setSelectionInterval(0, recursos.getModel().getSize() - 1);
        }
    });
    recursos.addListSelectionListener(listSelectionListener);
    final JScrollPane jScrollPaneR = new JScrollPane(recursos, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jScrollPaneR.getViewport().setPreferredSize(DIMENSION_JLIST);
    panel.add(jScrollPaneR);

    jLabel = new JLabel("Incidencias", SwingConstants.RIGHT);
    jLabel.setPreferredSize(ConsultaHistoricos.DIMENSION_LABEL);
    panel.add(jLabel);
    incidencias = new JList(new DefaultListModel());
    incidencias.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK), "selectAll");
    incidencias.getActionMap().put("selectAll", new AbstractAction() {

        private static final long serialVersionUID = -5515338515763292526L;

        @Override
        public void actionPerformed(ActionEvent e) {
            incidencias.setSelectionInterval(0, incidencias.getModel().getSize() - 1);
        }
    });
    incidencias.addListSelectionListener(listSelectionListener);
    final JScrollPane jScrollPaneI = new JScrollPane(incidencias, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jScrollPaneI.getViewport().setPreferredSize(DIMENSION_JLIST);
    panel.setPreferredSize(DIMENSION_2JLIST);
    panel.add(jScrollPaneI);
    return panel;
}

From source file:org.photovault.swingui.BrowserWindow.java

protected void createUI(PhotoCollection collection) {
    window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    tabPane = new JTabbedPane();
    queryPane = new QueryPane();
    PhotoFolderTreeController treeCtrl = new PhotoFolderTreeController(window, this);
    viewCtrl = new PhotoViewController(window, this);
    treePane = treeCtrl.folderTree;// ww  w  .j  a va 2s.  c  om
    viewPane = viewCtrl.getThumbPane();
    previewPane = viewCtrl.getPreviewPane();
    tabPane.addTab("Query", queryPane);
    tabPane.addTab("Folders", treePane);

    VolumeTreeController volTreeCtrl = new VolumeTreeController(this);
    JTree volumeTree = volTreeCtrl.getView();
    JScrollPane voltreeScrollPane = new JScrollPane(volumeTree);
    voltreeScrollPane.setPreferredSize(new Dimension(200, 500));
    tabPane.add("Volumes", voltreeScrollPane);

    // TODO: get rid of this!!!!
    EditSelectionColorsAction colorAction = (EditSelectionColorsAction) viewPane.getEditSelectionColorsAction();
    colorAction.setPreviewCtrl(previewPane);

    // Set listeners to both query and folder tree panes

    /*
    If an actionEvent comes from query pane, swich to query results.
     */
    queryPane.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setCollection(queryPane.getResultCollection());
        }
    });

    /*
    If the selected folder is changed in treePane, switch to that immediately
     */

    treeCtrl.registerEventListener(PhotoFolderTreeEvent.class, new DefaultEventListener<PhotoCollection>() {

        public void handleEvent(DefaultEvent<PhotoCollection> event) {
            PhotoCollection c = event.getPayload();
            if (c != null) {
                viewCtrl.setCollection(c);
                if (c instanceof PhotoFolder) {
                    PhotoFolder f = (PhotoFolder) c;

                    if (f.getExternalDir() != null) {
                        ExternalDir ed = f.getExternalDir();
                        folderIndexer.updateDir(ed.getVolume(), ed.getPath());
                        viewCtrl.setIndexingOngoing(true);
                    }
                }
            }
        }
    });

    volTreeCtrl.registerEventListener(PhotoFolderTreeEvent.class, new DefaultEventListener<PhotoCollection>() {

        public void handleEvent(DefaultEvent<PhotoCollection> event) {
            PhotoCollection c = event.getPayload();
            if (c != null) {
                viewCtrl.setCollection(c);
                if (c instanceof ExtDirPhotos) {
                    ExtDirPhotos photos = (ExtDirPhotos) c;
                    ExternalVolume vol = (ExternalVolume) viewCtrl.getDAOFactory().getVolumeDAO()
                            .getVolume(photos.getVolId());
                    folderIndexer.updateDir(vol, photos.getDirPath());
                    viewCtrl.setIndexingOngoing(true);
                }
            }
        }
    });

    collectionPane = viewCtrl.getCollectionPane();

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tabPane, collectionPane);
    split.putClientProperty(JSplitPane.ONE_TOUCH_EXPANDABLE_PROPERTY, new Boolean(true));
    Container cp = window.getContentPane();
    cp.setLayout(new BorderLayout());
    cp.add(split, BorderLayout.CENTER);

    statusBar = new StatusBar();
    cp.add(statusBar, BorderLayout.SOUTH);

    // Create actions for BrowserWindow UI

    ImageIcon indexDirIcon = getIcon("index_dir.png");
    DefaultAction indexDirAction = new DefaultAction("Index directory...", indexDirIcon) {

        public void actionPerformed(ActionEvent e) {
            indexDir();
        }
    };
    indexDirAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_D);
    indexDirAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Index all images in a directory");
    this.registerAction("new_ext_vol", indexDirAction);

    ImageIcon importIcon = getIcon("import.png");
    importAction = new AbstractAction("Import image...", importIcon) {

        public void actionPerformed(ActionEvent e) {
            importFile();
        }
    };
    importAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_O);
    importAction.putValue(AbstractAction.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

    importAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Import new image into database");

    ImageIcon updateIcon = getIcon("update_indexed_dirs.png");
    UpdateIndexAction updateIndexAction = new UpdateIndexAction(viewCtrl, "Update indexed dirs", updateIcon,
            "Check for changes in previously indexed directories", KeyEvent.VK_U);
    this.registerAction("update_indexed_dirs", updateIndexAction);
    updateIndexAction.addStatusChangeListener(statusBar);

    ImageIcon previewTopIcon = getIcon("view_preview_top.png");
    DefaultAction previewTopAction = new DefaultAction("Preview on top", previewTopIcon) {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setLayout(PhotoViewController.Layout.PREVIEW_HORIZONTAL_THUMBS);
        }
    };
    previewTopAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show preview on top of thumbnails");
    previewTopAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_T);
    this.registerAction("view_preview_top", previewTopAction);

    ImageIcon previewRightIcon = getIcon("view_preview_right.png");
    DefaultAction previewRightAction = new DefaultAction("Preview on right", previewRightIcon) {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setLayout(PhotoViewController.Layout.PREVIEW_VERTICAL_THUMBS);
        }
    };
    previewRightAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show preview on right of thumbnails");
    previewRightAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_R);
    this.registerAction("view_preview_right", previewRightAction);

    ImageIcon previewNoneIcon = getIcon("view_no_preview.png");
    DefaultAction previewNoneAction = new DefaultAction("No preview", previewNoneIcon) {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setLayout(PhotoViewController.Layout.ONLY_THUMBS);
        }
    };
    previewNoneAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show no preview image");
    previewNoneAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_O);
    this.registerAction("view_no_preview", previewNoneAction);

    DefaultAction previewLargeAction = new DefaultAction("Large", null) {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setPreviewSize(200);
        }
    };
    DefaultAction previewSmallAction = new DefaultAction("Small", null) {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setPreviewSize(100);
        }
    };

    JToolBar tb = createToolbar();
    cp.add(tb, BorderLayout.NORTH);

    // Create the menu bar & menus
    JMenuBar menuBar = new JMenuBar();
    window.setJMenuBar(menuBar);
    // File menu
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);

    JMenuItem newWindowItem = new JMenuItem("New window", KeyEvent.VK_N);
    newWindowItem.setIcon(getIcon("window_new.png"));
    newWindowItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            BrowserWindow br = new BrowserWindow(getParentController(), null);
            //          br.setVisible( true );
        }
    });
    fileMenu.add(newWindowItem);

    JMenuItem importItem = new JMenuItem(importAction);
    fileMenu.add(importItem);

    JMenuItem indexDirItem = new JMenuItem(indexDirAction);
    fileMenu.add(indexDirItem);

    fileMenu.add(new JMenuItem(viewCtrl.getActionAdapter("update_indexed_dirs")));

    ExportSelectedAction exportAction = (ExportSelectedAction) viewPane.getExportSelectedAction();
    JMenuItem exportItem = new JMenuItem(exportAction);
    exportAction.addStatusChangeListener(statusBar);
    fileMenu.add(exportItem);

    JMenu dbMenu = new JMenu("Database");
    dbMenu.setMnemonic(KeyEvent.VK_B);
    dbMenu.setIcon(getIcon("empty_icon.png"));

    ExportMetadataAction exportMetadata = new ExportMetadataAction("Export as XML...", null,
            "Export whole database as XML file", KeyEvent.VK_E);
    dbMenu.add(new JMenuItem(exportMetadata));

    ImportXMLAction importMetadata = new ImportXMLAction("Import XML data...", null,
            "Import data from other Photovault database as XML", KeyEvent.VK_I);
    importMetadata.addStatusChangeListener(statusBar);
    dbMenu.add(new JMenuItem(importMetadata));

    fileMenu.add(dbMenu);

    JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X);
    exitItem.setIcon(getIcon("exit.png"));
    exitItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    fileMenu.add(exitItem);

    JMenu viewMenu = new JMenu("View");
    viewMenu.setMnemonic(KeyEvent.VK_V);
    menuBar.add(viewMenu);

    JMenuItem vertIconsItem = new JMenuItem(previewRightAction);
    viewMenu.add(vertIconsItem);

    JMenuItem horzIconsItem = new JMenuItem(previewTopAction);
    viewMenu.add(horzIconsItem);

    JMenuItem noPreviewItem = new JMenuItem(previewNoneAction);
    viewMenu.add(noPreviewItem);

    JMenuItem nextPhotoItem = new JMenuItem(viewPane.getSelectNextAction());
    viewMenu.add(nextPhotoItem);

    JMenuItem prevPhotoItem = new JMenuItem(viewPane.getSelectPreviousAction());
    viewMenu.add(prevPhotoItem);

    viewMenu.add(new JMenuItem(previewSmallAction));
    viewMenu.add(new JMenuItem(previewLargeAction));

    JMenu sortMenu = new JMenu("Sort by");
    sortMenu.setMnemonic(KeyEvent.VK_S);
    sortMenu.setIcon(getIcon("empty_icon.png"));
    JMenuItem byDateItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new ShootingDateComparator(), "Date",
            null, "Order photos by date", KeyEvent.VK_D));
    sortMenu.add(byDateItem);
    JMenuItem byPlaceItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new ShootingPlaceComparator(),
            "Place", null, "Order photos by shooting place", KeyEvent.VK_P));
    sortMenu.add(byPlaceItem);
    JMenuItem byQualityItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new QualityComparator(),
            "Quality", null, "Order photos by quality", KeyEvent.VK_Q));
    sortMenu.add(byQualityItem);
    viewMenu.add(sortMenu);

    // Set default ordering by date
    byDateItem.getAction().actionPerformed(new ActionEvent(this, 0, "Setting default"));
    JMenu imageMenu = new JMenu("Image");
    imageMenu.setMnemonic(KeyEvent.VK_I);
    menuBar.add(imageMenu);

    imageMenu.add(new JMenuItem(viewPane.getEditSelectionPropsAction()));
    imageMenu.add(new JMenuItem(viewPane.getShowSelectedPhotoAction()));
    imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_cw")));
    imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_ccw")));
    imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_180")));
    imageMenu.add(new JMenuItem(previewPane.getCropAction()));
    imageMenu.add(new JMenuItem(viewPane.getEditSelectionColorsAction()));
    imageMenu.add(new JMenuItem(viewPane.getDeleteSelectedAction()));

    // Create the Quality submenu
    JMenu qualityMenu = new JMenu("Quality");
    qualityMenu.setIcon(getIcon("empty_icon.png"));

    for (int n = 0; n < 6; n++) {
        Action qualityAction = viewCtrl.getActionAdapter("quality_" + n);
        JMenuItem qualityMenuItem = new JMenuItem(qualityAction);
        qualityMenu.add(qualityMenuItem);
    }
    imageMenu.add(qualityMenu);

    JMenu aboutMenu = new JMenu("About");
    aboutMenu.setMnemonic(KeyEvent.VK_A);
    aboutMenu.add(new JMenuItem(new ShowAboutDlgAction("About Photovault...", null, "", null)));

    menuBar.add(Box.createHorizontalGlue());
    menuBar.add(aboutMenu);
    window.pack();
    window.setVisible(true);
}

From source file:SciTK.Plot.java

/** 
 * Load the initial UI//www .j  a  v  a 2  s .co m
 */
protected final void initUI() {
    setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    // create a ChartPanel, and make it default to 1/4 of screen size:
    chart_panel = new ChartPanel(chart);
    chart_panel.setPreferredSize(new Dimension(def_width, def_height));

    //add the chart to the window:
    getContentPane().add(chart_panel);

    // create a menu bar:
    menubar = new JMenuBar();
    // ---------------------------------------------------------
    //                 First dropdown menu: "File"
    // ---------------------------------------------------------
    file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);

    // Set up a save dialog option under the file menu:
    JMenuItem menu_file_save;
    ImageIcon menu_file_save_icon = null;
    try {
        menu_file_save_icon = new ImageIcon(getClass().getResource("/SciTK/resources/document-save-5.png"));
        menu_file_save = new JMenuItem("Save", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save = new JMenuItem("Save");
    }
    menu_file_save.setMnemonic(KeyEvent.VK_S);
    menu_file_save.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_file_save.setToolTipText("Save an image");
    menu_file_save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveImage();
        }
    });
    file.add(menu_file_save);

    // Set up a save SVG dialog option under the file menu:
    JMenuItem menu_file_save_svg;
    try {
        menu_file_save_svg = new JMenuItem("Save VG", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save_svg = new JMenuItem("Save VG");
    }
    menu_file_save_svg.setToolTipText("Save as vector graphics (SVG,PS,EPS)");
    menu_file_save_svg.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveVectorGraphics();
        }
    });
    file.add(menu_file_save_svg);

    // Set up a save data dialog option under the file menu:
    JMenuItem menu_file_save_data;
    try {
        menu_file_save_data = new JMenuItem("Save data", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save_data = new JMenuItem("Save data");
    }
    menu_file_save_data.setToolTipText("Save raw data to file");
    menu_file_save_data.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveData();
        }
    });
    file.add(menu_file_save_data);

    // Set up a save data dialog option under the file menu:
    JMenuItem menu_file_print;
    try {
        ImageIcon menu_file_print_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/document-print-5.png"));
        menu_file_print = new JMenuItem("Print", menu_file_print_icon);
    } catch (Exception e) {
        menu_file_print = new JMenuItem("Print");
    }
    menu_file_print.setToolTipText("Print image of chart");
    menu_file_print.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            printPlot();
        }
    });
    file.add(menu_file_print);

    // menu item for exiting
    JMenuItem menu_file_exit;
    try {
        ImageIcon menu_file_exit_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/application-exit.png"));
        menu_file_exit = new JMenuItem("Exit", menu_file_exit_icon);
    } catch (Exception e) {
        menu_file_exit = new JMenuItem("Exit");
    }
    menu_file_exit.setMnemonic(KeyEvent.VK_X);
    menu_file_exit.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_file_exit.setToolTipText("Exit application");
    menu_file_exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dispose();
        }

    });
    file.add(menu_file_exit);

    // ---------------------------------------------------------
    //                 Second dropdown menu: "Edit"
    // ---------------------------------------------------------
    edit = new JMenu("Edit");
    edit.setMnemonic(KeyEvent.VK_E);

    // copy to clipboard
    JMenuItem menu_edit_copy_image;
    ImageIcon menu_edit_copy_icon = null;
    try {
        menu_edit_copy_icon = new ImageIcon(getClass().getResource("/SciTK/resources/edit-copy-7.png"));
        menu_edit_copy_image = new JMenuItem("Copy", menu_edit_copy_icon);
    } catch (Exception e) {
        menu_edit_copy_image = new JMenuItem("Copy");
    }
    menu_edit_copy_image.setMnemonic(KeyEvent.VK_C);
    menu_edit_copy_image.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_edit_copy_image.setToolTipText("Copy image to clipboard");
    menu_edit_copy_image.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            copyImage();
        }
    });
    edit.add(menu_edit_copy_image);

    // copy data to clipboard
    JMenuItem menu_edit_copy_data;
    try {
        menu_edit_copy_data = new JMenuItem("Copy data", menu_edit_copy_icon);
    } catch (Exception e) {
        menu_edit_copy_data = new JMenuItem("Copy data");
    }
    menu_edit_copy_data.setToolTipText("Copy data to clipboard");
    menu_edit_copy_data.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            copyData();
        }
    });
    edit.add(menu_edit_copy_data);

    // set background color
    JMenuItem menu_edit_BackgroundColor;
    ImageIcon menu_edit_Color_icon = null;
    try {
        menu_edit_Color_icon = new ImageIcon(getClass().getResource("/SciTK/resources/color-wheel.png"));
        menu_edit_BackgroundColor = new JMenuItem("Background Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_BackgroundColor = new JMenuItem("Background Color");
    }
    menu_edit_BackgroundColor.setToolTipText("Select background color");
    menu_edit_BackgroundColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color bgColor = plotColorChooser("Choose background color", (Color) chart.getBackgroundPaint());
            setBackgroundColor(bgColor);
        }
    });
    edit.add(menu_edit_BackgroundColor);

    // set plot color
    JMenuItem menu_edit_PlotColor;
    try {
        menu_edit_PlotColor = new JMenuItem("Window Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_PlotColor = new JMenuItem("Window Color");
    }
    menu_edit_PlotColor.setToolTipText("Select plot window color");
    menu_edit_PlotColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color plotColor = plotColorChooser("Choose plot color",
                    (Color) chart.getPlot().getBackgroundPaint());
            setWindowBackground(plotColor);
        }
    });
    edit.add(menu_edit_PlotColor);

    // set gridline color
    JMenuItem menu_edit_GridlineColor;
    try {
        menu_edit_GridlineColor = new JMenuItem("Gridline Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_GridlineColor = new JMenuItem("Gridline Color");
    }
    menu_edit_GridlineColor.setToolTipText("Select grid color");
    menu_edit_GridlineColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color gridColor = plotColorChooser("Choose grid color",
                    (Color) chart.getPlot().getBackgroundPaint());
            setGridlineColor(gridColor);
        }
    });
    edit.add(menu_edit_GridlineColor);

    // edit chart preferences
    JMenuItem menu_edit_preferences;
    try {
        ImageIcon menu_edit_preferences_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/preferences-desktop-3.png"));
        menu_edit_preferences = new JMenuItem("Preferences", menu_edit_preferences_icon);
    } catch (Exception e) {
        menu_edit_preferences = new JMenuItem("Preferences");
    }
    menu_edit_preferences.setToolTipText("Edit chart preferences");
    menu_edit_preferences.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            chart_panel.doEditChartProperties();
        }
    });
    edit.add(menu_edit_preferences);

    // ---------------------------------------------------------
    //                 Third dropdown menu: "Plot"
    // ---------------------------------------------------------
    plot = new JMenu("Plot");
    plot.setMnemonic(KeyEvent.VK_P);

    // Options to set log axes
    JCheckBoxMenuItem menu_plot_ylog = new JCheckBoxMenuItem("Log y axis");
    menu_plot_ylog.setToolTipText("Set y axis to logarithmic");
    menu_plot_ylog.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setRangeAxisLog(selected);
        }
    });
    plot.add(menu_plot_ylog);

    JCheckBoxMenuItem menu_plot_xlog = new JCheckBoxMenuItem("Log x axis");
    menu_plot_xlog.setToolTipText("Set x axis to logarithmic");
    menu_plot_xlog.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setDomainAxisLog(selected);
        }
    });
    plot.add(menu_plot_xlog);

    // grid line display
    JCheckBoxMenuItem menu_plot_grid = new JCheckBoxMenuItem("Grid lines");
    menu_plot_grid.setToolTipText("Show plot grid lines?");
    menu_plot_grid.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setGridlineVisible(selected);
        }
    });
    // set appropirate checkbox state:
    menu_plot_grid.setState(chart.getXYPlot().isDomainGridlinesVisible());
    plot.add(menu_plot_grid);

    // control for displaying plot legend
    JCheckBoxMenuItem menu_plot_legend = new JCheckBoxMenuItem("Legend");
    menu_plot_legend.setToolTipText("Show plot legend?");
    menu_plot_legend.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setLegend(selected);
        }
    });
    // set appropirate checkbox state:
    menu_plot_legend.setState((chart.getLegend() instanceof LegendTitle));
    plot.add(menu_plot_legend);

    // ---------------------------------------------------------
    //                 General UI
    // ---------------------------------------------------------
    // Add menus to the menu bar:
    menubar.add(file);
    menubar.add(edit);
    menubar.add(plot);
    // Set menubar as this JFrame's menu
    setJMenuBar(menubar);

    // set default plot colors:
    chart.setBackgroundPaint(new Color(255, 255, 255, 0));
    chart.getPlot().setBackgroundPaint(new Color(255, 255, 255, 255));
    setBackgroundAlpha(0.0f);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    pack();
    setTitle(window_title);
    setLocationRelativeTo(null);
    setVisible(true);
}

From source file:com.googlecode.bpmn_simulator.gui.BPMNSimulatorFrame.java

@Override
protected JMenu createWindowMenu() {
    final JMenu menuWindow = new JMenu(Messages.getString("Menu.windows")); //$NON-NLS-1$

    final JMenuItem menuWindowElements = new JMenuItem(Messages.getString("Menu.elements")); //$NON-NLS-1$
    menuWindowElements.setMnemonic(KeyEvent.VK_E);
    menuWindowElements.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK));
    menuWindowElements.addActionListener(new ActionListener() {
        @Override/*from   w w  w. ja v a2 s.  co  m*/
        public void actionPerformed(final ActionEvent e) {
            showElementsFrame();
        }
    });
    menuWindow.add(menuWindowElements);

    final JMenuItem menuWindowInstances = new JMenuItem(Messages.getString("Menu.instances")); //$NON-NLS-1$
    menuWindowInstances.setMnemonic(KeyEvent.VK_I);
    menuWindowInstances.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.ALT_MASK));
    menuWindowInstances.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            showInstancesFrame();
        }
    });
    menuWindow.add(menuWindowInstances);

    final JMenu menuWindowDiagram = super.createWindowMenu();
    menuWindowDiagram.setText(Messages.getString("Menu.diagrams"));
    menuWindow.add(menuWindowDiagram);

    return menuWindow;
}