Example usage for java.awt.event KeyEvent VK_S

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

Introduction

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

Prototype

int VK_S

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

Click Source Link

Document

Constant for the "S" key.

Usage

From source file:com.pingtel.sipviewer.SIPViewerFrame.java

protected void initMenu() {
    JMenu menu;//from  w  ww  . jav  a  2s.  c o m
    JMenu submenu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMenuItem;

    // Create the menu bar.
    JMenuBar menuBar = new JMenuBar();
    this.setJMenuBar(menuBar);

    // Build the File menu.
    menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(menu);

    // Add the load-file items to the File menu.
    menuItem = new JMenuItem();
    menuItem.setAction(new icOpenFileAction());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.ALT_MASK));
    menuItem.setMnemonic(KeyEvent.VK_F);
    menu.add(menuItem);

    menuItem = new JMenuItem();
    menuItem.setAction(new icImportSyslogAction());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, ActionEvent.ALT_MASK));
    menuItem.setMnemonic(KeyEvent.VK_Y);
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem();
    menuItem.setAction(new icSaveAsAction());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.ALT_MASK));
    menuItem.setMnemonic(KeyEvent.VK_S);
    menu.add(menuItem);

    menu.addSeparator();

    // Add the reload item to the File menu.
    menuItem = new JMenuItem();
    menuItem.setAction(new icReloadAction());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK));
    menuItem.setMnemonic(KeyEvent.VK_R);
    menu.add(menuItem);

    menu.addSeparator();

    // Add the quit item to the File menu.
    menuItem = new JMenuItem();
    menuItem.setAction(new icQuitAction());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK));
    menuItem.setMnemonic(KeyEvent.VK_Q);
    menu.add(menuItem);

    // Build the Options menu.
    menu = new JMenu("Options");
    menu.setMnemonic(KeyEvent.VK_O);
    menuBar.add(menu);

    // Add the split/single screen mode to the options menu
    menuItem = new JMenuItem();
    menuItem.setAction(new icScreenModeAction());
    menuItem.setMnemonic(KeyEvent.VK_M);
    menu.add(menuItem);

    menu.addSeparator();

    // Add the show all dialogs option to the options menu
    menuItem = new JMenuItem();
    menuItem.setAction(new icShowAllDialogsAction());
    menuItem.setMnemonic(KeyEvent.VK_D);
    menu.add(menuItem);

    menu.addSeparator();

    // Add the Time Zone Selection Time submenu
    submenu = new JMenu("Time Zone Setting");
    submenu.setMnemonic(KeyEvent.VK_Z);

    ButtonGroup timeZoneGroup = new ButtonGroup();

    // Set Time Zone to Local Time Zone
    m_localTimeZone = new JRadioButtonMenuItem();
    m_localTimeZone.setAction(new icSetTimeToLocalZone());
    m_localTimeZone.setMnemonic(KeyEvent.VK_L);
    timeZoneGroup.add(m_localTimeZone);
    m_localTimeZone.setSelected(true);
    submenu.add(m_localTimeZone);

    // Set Time Zone to UTC Time Zone
    m_utcTimeZone = new JRadioButtonMenuItem();
    m_utcTimeZone.setAction(new icSetTimeToUTCZone());
    m_utcTimeZone.setMnemonic(KeyEvent.VK_U);
    timeZoneGroup.add(m_utcTimeZone);
    submenu.add(m_utcTimeZone);

    menu.add(submenu);

    // Add the show/hide time index column
    menuItem = new JMenuItem();
    menuItem.setAction(new icTimeVisibilityAction());
    menuItem.setMnemonic(KeyEvent.VK_V);
    menu.add(menuItem);

    // Add the Time Display Format submenu
    submenu = new JMenu("Time Display Format");
    submenu.setMnemonic(KeyEvent.VK_T);

    ButtonGroup group = new ButtonGroup();
    m_dateAndTimeFormat = new JRadioButtonMenuItem();
    m_dateAndTimeFormat.setAction(new icDateAndTimeAction());
    m_dateAndTimeFormat.setMnemonic(KeyEvent.VK_I);
    group.add(m_dateAndTimeFormat);
    submenu.add(m_dateAndTimeFormat);

    m_defaultTimeFormat = new JRadioButtonMenuItem();
    m_defaultTimeFormat.setAction(new icTimeOfDay());
    m_defaultTimeFormat.setMnemonic(KeyEvent.VK_E);
    m_defaultTimeFormat.setSelected(true);
    group.add(m_defaultTimeFormat);
    submenu.add(m_defaultTimeFormat);

    m_sincePreviousFormat = new JRadioButtonMenuItem();
    m_sincePreviousFormat.setAction(new icSincePrevious());
    m_sincePreviousFormat.setMnemonic(KeyEvent.VK_P);
    group.add(m_sincePreviousFormat);
    submenu.add(m_sincePreviousFormat);

    m_sinceBeginningFormat = new JRadioButtonMenuItem();
    m_sinceBeginningFormat.setAction(new icSinceBeginning());
    m_sinceBeginningFormat.setMnemonic(KeyEvent.VK_B);
    group.add(m_sinceBeginningFormat);
    submenu.add(m_sinceBeginningFormat);

    m_sinceKeyIndexFormat = new JRadioButtonMenuItem();
    m_sinceKeyIndexFormat.setAction(new icSinceKeyIndex());
    m_sinceKeyIndexFormat.setMnemonic(KeyEvent.VK_K);
    group.add(m_sinceKeyIndexFormat);
    submenu.add(m_sinceKeyIndexFormat);

    menu.add(submenu);

    // Build the Help menu.
    menu = new JMenu("Help");
    menu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(menu);

    // Add the items to the File menu.
    menuItem = new JMenuItem();
    menuItem.setAction(new icAboutAction());
    menu.add(menuItem);
}

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

/**
 * This method initializes jButton1   // ww  w.j  av  a  2 s  . c o m
 *    
 * @return javax.swing.JButton   
 */
private JButton getJButtonSave() {
    if (jButtonSave == null) {
        jButtonSave = new JButton();
        jButtonSave.setText("Save Template");
        jButtonSave.setEnabled(false);
        jButtonSave.setMnemonic(KeyEvent.VK_S);
        jButtonSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                jLabelFeedback.setText(" ");
                if (template.isEditable()) {
                    template.setTemplateId(jTextFieldTemplateId.getText());
                    template.setTemplateName(jTextFieldName.getText());
                    template.setImageSize(imagePanelForDrawing.getImageSize());
                    try {
                        if (template.getTemplateId().trim().equals("")) {
                            throw new BadTemplateException("Template ID can't be blank.");
                        }
                        if (template.getReferenceImage() == null) {
                            ICImageLifeCycle ils = new ICImageLifeCycle();
                            ICImage imageToFind = new ICImage();
                            imageToFind.setFilename(referenceImageFilename);
                            List<ICImage> images = ils.findByExample(imageToFind);
                            if (!images.isEmpty()) {
                                template.setReferenceImage(images.get(0));
                            } else {
                                //create a new image record
                                ICImage newImage = new ICImage();
                                newImage.setFilename(referenceImageFilename);
                                // path should be relative to the base path
                                // just substituting won't work for images off the base path.
                                String startPointName = Singleton.getSingletonInstance().getProperties()
                                        .getProperties().getProperty(ImageCaptureProperties.KEY_IMAGEBASE);
                                newImage.setPath(referenceImagePath.replaceAll(startPointName, "")
                                        .replaceAll(referenceImageFilename + "$", ""));
                                newImage.setTemplateId(template.getTemplateId());
                                ils.persist(newImage);
                                if (referenceImageFilename != null) {
                                    jTextFieldImageFileName.setText(referenceImageFilename);
                                }
                            }
                        }

                        //TODO: Check that template is valid, not overlapping with existing template.
                        //Test images IMG_00005.jpg and IMG_00001.jpg suggest that overlapping templates might
                        //be needed - where all parameters except extent of barcode are the same.  

                        template.persist();

                        jLabelFeedback.setText("Saved " + template.getTemplateId());

                    } catch (BadTemplateException e1) {
                        JOptionPane.showMessageDialog(thisFrame,
                                "Error. Unable to save template, invalid data. " + e1.getMessage(),
                                "Error:BadTemplateData", JOptionPane.ERROR_MESSAGE);
                        log.debug(e1);
                    } catch (SaveFailedException e2) {
                        JOptionPane.showMessageDialog(thisFrame,
                                "Error. Unable to save template. " + e2.getMessage(), "Error:SaveFailed",
                                JOptionPane.ERROR_MESSAGE);
                        log.debug(e2);
                    }
                }
            }
        });
    }
    return jButtonSave;
}

From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java

/**
 * Creates a new RegistryBrowser object.
 */// w w  w  .j  a  va 2 s .c  o  m
@SuppressWarnings("unchecked")
private RegistryBrowser() {
    instance = this;

    classLoader = getClass().getClassLoader(); // new
    // JAXRBrowserClassLoader(getClass().getClassLoader());
    Thread.currentThread().setContextClassLoader(classLoader);

    /*
     * try { classLoader.loadClass("javax.xml.soap.SOAPMessage"); } catch
     * (ClassNotFoundException e) {
     * log.error("Could not find class javax.xml.soap.SOAPMessage", e); }
     */

    UIManager.addPropertyChangeListener(new UISwitchListener(getRootPane()));

    // add listener for 'locale' bound property
    addPropertyChangeListener(PROPERTY_LOCALE, this);

    menuBar = new JMenuBar();
    fileMenu = new JMenu();
    editMenu = new JMenu();
    viewMenu = new JMenu();
    helpMenu = new JMenu();

    JSeparator JSeparator1 = new JSeparator();
    newItem = new JMenuItem();
    importItem = new JMenuItem();
    saveItem = new JMenuItem();
    saveAsItem = new JMenuItem();
    exitItem = new JMenuItem();
    cutItem = new JMenuItem();
    copyItem = new JMenuItem();
    pasteItem = new JMenuItem();
    aboutItem = new JMenuItem();
    setJMenuBar(menuBar);
    setTitle(resourceBundle.getString("title.registryBrowser.java"));
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    // Scale window to be centered using 70% of screen
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

    setBounds((int) (dim.getWidth() * .15), (int) (dim.getHeight() * .1), (int) (dim.getWidth() * .7),
            (int) (dim.getHeight() * .75));
    setVisible(false);
    saveFileDialog.setMode(FileDialog.SAVE);
    saveFileDialog.setTitle(resourceBundle.getString("dialog.save.title"));

    GridBagLayout gb = new GridBagLayout();

    topPanel.setLayout(gb);
    getContentPane().add("North", topPanel);

    GridBagConstraints c = new GridBagConstraints();
    toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
    toolbarPanel.setBounds(0, 0, 488, 29);

    discoveryToolBar = createDiscoveryToolBar();
    toolbarPanel.add(discoveryToolBar);

    // c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 0);
    gb.setConstraints(toolbarPanel, c);
    topPanel.add(toolbarPanel);

    // Panel containing context info like registry location and user context
    JPanel contextPanel = new JPanel();
    GridBagLayout gb1 = new GridBagLayout();
    contextPanel.setLayout(gb1);

    locationLabel = new JLabel(resourceBundle.getString("label.registryLocation"));

    // locationLabel.setPreferredSize(new Dimension(80, 23));
    // c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 0, 0);
    gb1.setConstraints(locationLabel, c);

    // contextPanel.setBackground(Color.green);
    contextPanel.add(locationLabel);

    selectAnItemText = new ItemText(selectAnItem);
    registryCombo.addItem(selectAnItemText.toString());

    ConfigurationType uiConfigurationType = UIUtility.getInstance().getConfigurationType();
    RegistryURIListType urlList = uiConfigurationType.getRegistryURIList();

    List<String> urls = urlList.getRegistryURI();
    Iterator<String> urlsIter = urls.iterator();
    while (urlsIter.hasNext()) {
        ItemText url = new ItemText(urlsIter.next());
        registryCombo.addItem(url.toString());
    }

    registryCombo.setEditable(true);
    registryCombo.setEnabled(true);
    registryCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            final String url = (String) registryCombo.getSelectedItem();
            if ((url == null) || (url.equals(selectAnItem))) {
                return;
            }

            // Clean tabbedPaneParent. Will create new content
            tabbedPaneParent.removeAll();
            conceptsTreeDialog = null;
            ConceptsTreeDialog.clearCache();

            // design:
            // 1. connect and construct tabbedPane in a now swing thread
            // 2. add tabbedPane in swing thread
            // 3. call reloadModel that should use WingWorkers
            final SwingWorker worker1 = new SwingWorker(RegistryBrowser.this) {
                public Object doNonUILogic() {
                    try {
                        // Try to connect
                        if (connectToRegistry(url)) {
                            return new JBTabbedPane();
                        }
                    } catch (JAXRException e1) {
                        displayError(e1);
                    }
                    return null;
                }

                public void doUIUpdateLogic() {
                    tabbedPane = (JBTabbedPane) get();
                    if (tabbedPane != null) {
                        tabbedPaneParent.add(tabbedPane, BorderLayout.CENTER);
                        tabbedPane.reloadModel();
                        try {
                            // DBH 1/30/04 - Add the submissions panel if
                            // the user is authenticated.
                            ConnectionImpl connection = RegistryBrowser.client.connection;
                            boolean newValue = connection.isAuthenticated();
                            firePropertyChange(PROPERTY_AUTHENTICATED, false, newValue);
                            getRootPane().updateUI();
                        } catch (JAXRException e1) {
                            displayError(e1);
                        }
                    }
                }
            };
            worker1.start();
        }
    });
    // c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 5, 0);
    gb1.setConstraints(registryCombo, c);
    contextPanel.add(registryCombo);

    JLabel currentUserLabel = new JLabel(resourceBundle.getString("label.currentUser"),
            SwingConstants.TRAILING);
    c.gridx = 2;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    gb1.setConstraints(currentUserLabel, c);

    // contextPanel.add(currentUserLabel);
    currentUserText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            @SuppressWarnings("unused")
            String text = currentUserText.getText();
        }
    });

    currentUserText.setEditable(false);
    c.gridx = 3;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 5, 5);
    gb1.setConstraints(currentUserText, c);

    // contextPanel.add(currentUserText);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 0, 0);
    gb.setConstraints(contextPanel, c);
    topPanel.add(contextPanel, c);

    tabbedPaneParent.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    tabbedPaneParent.setLayout(new BorderLayout());
    tabbedPaneParent.setToolTipText(resourceBundle.getString("tabbedPane.tip"));

    getContentPane().add("Center", tabbedPaneParent);

    fileMenu.setText(resourceBundle.getString("menu.file"));
    fileMenu.setActionCommand("File");
    fileMenu.setMnemonic((int) 'F');
    menuBar.add(fileMenu);

    saveItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    saveItem.setText(resourceBundle.getString("menu.save"));
    saveItem.setActionCommand("Save");
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));
    saveItem.setMnemonic((int) 'S');

    // fileMenu.add(saveItem);
    fileMenu.add(JSeparator1);
    importItem.setText(resourceBundle.getString("menu.import"));
    importItem.setActionCommand("Import");
    importItem.setMnemonic((int) 'I');
    importItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            RegistryBrowser.setWaitCursor();
            importFromFile();
            RegistryBrowser.setDefaultCursor();
        }
    });
    fileMenu.add(importItem);

    exitItem.setText(resourceBundle.getString("menu.exit"));
    exitItem.setActionCommand("Exit");
    exitItem.setMnemonic((int) 'X');
    fileMenu.add(exitItem);

    editMenu.setText(resourceBundle.getString("menu.edit"));
    editMenu.setActionCommand("Edit");
    editMenu.setMnemonic((int) 'E');

    // menuBar.add(editMenu);
    cutItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    cutItem.setText(resourceBundle.getString("menu.cut"));
    cutItem.setActionCommand("Cut");
    cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK));
    cutItem.setMnemonic((int) 'T');
    editMenu.add(cutItem);

    copyItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    copyItem.setText(resourceBundle.getString("menu.copy"));
    copyItem.setActionCommand("Copy");
    copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
    copyItem.setMnemonic((int) 'C');
    editMenu.add(copyItem);

    pasteItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    pasteItem.setText(resourceBundle.getString("menu.paste"));
    pasteItem.setActionCommand("Paste");
    pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK));
    pasteItem.setMnemonic((int) 'P');
    editMenu.add(pasteItem);

    viewMenu.setText(resourceBundle.getString("menu.view"));
    viewMenu.setActionCommand("view");
    viewMenu.setMnemonic((int) 'V');

    themeMenu = new MetalThemeMenu(resourceBundle.getString("menu.theme"), themes);
    viewMenu.add(themeMenu);
    menuBar.add(viewMenu);

    helpMenu.setText(resourceBundle.getString("menu.help"));
    helpMenu.setActionCommand("Help");
    helpMenu.setMnemonic((int) 'H');
    menuBar.add(helpMenu);
    aboutItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    aboutItem.setText(resourceBundle.getString("menu.about"));
    aboutItem.setActionCommand("About...");
    aboutItem.setMnemonic((int) 'A');

    aboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object[] aboutArgs = { BROWSER_VERSION };
            MessageFormat form = new MessageFormat(resourceBundle.getString("dialog.about.text"));
            JOptionPane.showMessageDialog(RegistryBrowser.this, form.format(aboutArgs),
                    resourceBundle.getString("dialog.about.title"), JOptionPane.INFORMATION_MESSAGE);
        }
    });

    helpMenu.add(aboutItem);

    // REGISTER_LISTENERS
    SymWindow aSymWindow = new SymWindow();

    this.addWindowListener(aSymWindow);

    SymAction lSymAction = new SymAction();

    saveItem.addActionListener(lSymAction);
    exitItem.addActionListener(lSymAction);

    SwingUtilities.updateComponentTreeUI(getContentPane());
    SwingUtilities.updateComponentTreeUI(menuBar);
    SwingUtilities.updateComponentTreeUI(fileChooser);

    // Auto select the registry that is configured to connect to by default
    String selectedIndexStr = ProviderProperties.getInstance()
            .getProperty("jaxr-ebxml.registryBrowser.registryLocationCombo.initialSelectionIndex", "0");

    int index = Integer.parseInt(selectedIndexStr);

    try {
        registryCombo.setSelectedIndex(index);
    } catch (IllegalArgumentException e) {
        Object[] invalidIndexArguments = { new Integer(index) };
        MessageFormat form = new MessageFormat(resourceBundle.getString("message.error.invalidIndex"));
        displayError(form.format(invalidIndexArguments), e);
    }
}

From source file:JXTransformer.java

public TransformerDemo() {
        super("Transformer demo");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JMenuBar bar = new JMenuBar();
        JMenu lafMenu = new JMenu("LaF");

        JMenuItem winLaf = new JMenuItem("Windows LaF");
        lafMenu.add(winLaf);/*  ww w.  j a va2  s  .c o  m*/
        winLaf.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                setLaf("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            }
        });
        JMenuItem motifLaf = new JMenuItem("Motif LaF");
        lafMenu.add(motifLaf);
        motifLaf.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                setLaf("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
            }
        });
        bar.add(lafMenu);
        JMenuItem metalLaf = new JMenuItem("Metal LaF");
        lafMenu.add(metalLaf);
        metalLaf.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                setLaf("javax.swing.plaf.metal.MetalLookAndFeel");
            }
        });

        JMenu settingsMenu = new JMenu("Settings");
        settingsMenu.setMnemonic(KeyEvent.VK_S);
        JMenuItem item = new JMenuItem("Reset sliders", KeyEvent.VK_R);
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_MASK));
        item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                rotationSlider.setValue(0);
                scalingSlider.setValue(100);
                shearingSlider.setValue(0);
            }
        });
        settingsMenu.add(item);
        bar.add(settingsMenu);
        setJMenuBar(bar);

        JPanel panel = new JPanel(new BorderLayout());
        panel.add(createDemoPanel());
        panel.add(createStressTestPanel(), BorderLayout.EAST);
        add(new JScrollPane(panel));
        add(new JScrollPane(createToolPanel()), BorderLayout.SOUTH);
        pack();
    }

From source file:com.intuit.tank.proxy.ProxyApp.java

/**
 * /*from   w  w w.  j av a 2s.com*/
 */
@SuppressWarnings("serial")
private void createActions() {

    startAction = new AbstractAction("Start Recording", loadImage("icons/16/control_play_blue.png")) {
        public void actionPerformed(ActionEvent arg0) {
            try {
                start();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(ProxyApp.this, "Error statrting proxy: " + e.toString(), "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }

    };
    startAction.putValue(javax.swing.Action.SHORT_DESCRIPTION, "Start Recording");

    stopAction = new AbstractAction("Stop Recording", loadImage("icons/16/control_stop_blue.png")) {
        public void actionPerformed(ActionEvent arg0) {
            try {
                stop();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(ProxyApp.this, "Error stopping proxy: " + e.toString(), "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }

    };
    stopAction.setEnabled(false);
    stopAction.putValue(javax.swing.Action.SHORT_DESCRIPTION, "Stop Recording");

    pauseAction = new AbstractAction("Pause Recording", loadImage("icons/16/control_pause_blue.png")) {
        public void actionPerformed(ActionEvent arg0) {
            pause();
        }
    };
    pauseAction.setEnabled(false);
    pauseAction.putValue(javax.swing.Action.SHORT_DESCRIPTION, "Pause Recording");

    settingsAction = new AbstractAction("Settings", loadImage("icons/16/cog.png")) {
        public void actionPerformed(ActionEvent arg0) {
            showSettings();
        }

    };
    settingsAction.putValue(javax.swing.Action.SHORT_DESCRIPTION, "Settings");

    filterAction = new AbstractAction("Run Filters", loadImage("icons/16/filter.png")) {
        public void actionPerformed(ActionEvent arg0) {
            filter();
        }

    };
    filterAction.putValue(javax.swing.Action.SHORT_DESCRIPTION, "Run Filters");
    filterAction.setEnabled(false);

    saveAction = new AbstractAction("Save", loadImage("icons/16/save_as.png")) {
        public void actionPerformed(ActionEvent arg0) {
            save();
        }

    };
    saveAction.setEnabled(false);
    saveAction.putValue(javax.swing.Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask));
    saveAction.putValue(javax.swing.Action.SHORT_DESCRIPTION, "Save");

    openAction = new AbstractAction("Open Recording...", loadImage("icons/16/folder_go.png")) {
        public void actionPerformed(ActionEvent arg0) {
            openRecording();
        }

    };
    openAction.putValue(javax.swing.Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, keyMask));
    openAction.putValue(javax.swing.Action.SHORT_DESCRIPTION, "Open Recording...");

    showHostsAction = new AbstractAction("Hosts...", loadImage("icons/16/page_add.png")) {
        public void actionPerformed(ActionEvent arg0) {
            showHosts();
        }

    };
    showHostsAction.putValue(javax.swing.Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_H, keyMask));
    showHostsAction.putValue(javax.swing.Action.SHORT_DESCRIPTION, "Show Hosts...");

    fileChooser = new JFileChooser(new File("."));
    fileChooser.setDialogTitle("Open Recording...");
    fileChooser.setFileFilter(new XmlFileFilter());
}

From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Actually builds the UI//w w  w.j  a  v  a 2s  . c  o m
 * @throws Exception
 */
private void jbInit() throws Exception {
    //Initialize the table which contains the log traces
    processInstanceIDsTable = new DoubleClickTable(new ExtendedLogTable(), updateButton);
    // select all rows as at the beginning the results count for the whole log
    processInstanceIDsTable.getSelectionModel().addSelectionInterval(0, extendedLog.getSizeOfLog() - 1);

    tableContainer = new JScrollPane(processInstanceIDsTable);

    //initialize the westPanel (which contains the processInstanceIDsTable)
    westPanel.setPreferredSize(new Dimension(100, 300));
    westPanel.setLayout(new BorderLayout());
    westPanel.add(tableContainer, BorderLayout.CENTER);
    updateButton.setToolTipText("Update metrics to the selected process instances");
    westPanel.add(piButtonsPanel, BorderLayout.SOUTH);
    piButtonsPanel.setLayout(new BorderLayout());
    piButtonsPanel.add(updateButton, BorderLayout.CENTER);
    piButtonsPanel.add(invertButton, BorderLayout.SOUTH);

    //initialize the eastpanel (which contains the process-metrics)
    eastPanel.setPreferredSize(new Dimension(240, 390));
    eastPanel.setMinimumSize(new Dimension(240, 390));
    eastPanel.setLayout(new GridBagLayout());
    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = 0;
    cons.gridy = 0;
    cons.insets = new Insets(0, 5, 5, 0);
    cons.anchor = GridBagConstraints.WEST;
    processLabel.setFont(new Font("SansSerif", Font.BOLD, 16));
    eastPanel.add(processLabel, cons);
    cons.gridx = 0;
    cons.gridy = 1;
    cons.insets = new Insets(8, 8, 0, 0);
    eastPanel.add(numberProcessLabel, cons);
    casesProcessLabel.setText(extendedLog.getSizeOfLog() + " cases");
    casesProcessLabel.setFont(new Font("SansSerif", Font.PLAIN, 11));
    cons.gridx = 0;
    cons.gridy = 2;
    eastPanel.add(casesProcessLabel, cons);
    cons.gridx = 0;
    cons.gridy = 3;
    eastPanel.add(properLabel, cons);
    completedLabel.setFont(new Font("SansSerif", Font.PLAIN, 11));
    cons.gridx = 0;
    cons.gridy = 4;
    eastPanel.add(completedLabel, cons);
    cons.gridx = 0;
    cons.gridy = 5;
    eastPanel.add(arrivalProcessLabel, cons);
    rateProcessLabel.setFont(new Font("SansSerif", Font.PLAIN, 11));
    cons.gridx = 0;
    cons.gridy = 6;
    eastPanel.add(rateProcessLabel, cons);
    cons.gridx = 0;
    cons.gridy = 7;
    cons.gridwidth = 2;
    cons.insets = new Insets(15, 5, 0, 2);
    cons.ipadx = 300;
    eastPanel.add(processTablePanel, cons);
    cons.gridx = 0;
    cons.gridy = 8;
    cons.gridwidth = 1;
    cons.insets = new Insets(0, 5, 0, 0);
    cons.weightx = 1;
    cons.ipadx = 0;
    exportProcessButton.setPreferredSize(new Dimension(110, 42));
    exportProcessButton.setMaximumSize(new Dimension(110, 42));
    changeProcessPercButton.setPreferredSize(new Dimension(110, 42));
    changeProcessPercButton.setMaximumSize(new Dimension(110, 42));
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.setPreferredSize(new Dimension(240, 42));
    buttonPanel.add(changeProcessPercButton);
    buttonPanel.add(exportProcessButton);
    eastPanel.add(buttonPanel, cons);

    processContainer = new JScrollPane(eastPanel);
    processContainer.setPreferredSize(new Dimension(240, 390));
    //initialize the processTablePanel (which contains the table with throughput times)
    processTablePanel.setLayout(new BorderLayout());
    processTablePanel.setMinimumSize(new Dimension(240, 130));
    processTablePanel.setPreferredSize(new Dimension(240, 130));
    processTable.setRowSelectionAllowed(false);
    processTablePanel.add(processTable.getTableHeader(), BorderLayout.PAGE_START);
    processTablePanel.add(processTable, BorderLayout.CENTER);

    //initialize the grappaPanel (which contains the Petri net UI) and place
    //it on the centerPanel
    grappaPanel = replayResult.getVisualization(extendedLog.getLogTraceIDs());
    grappaPanel.addGrappaListener(new ExtendedGrappaAdapter());
    mapping = new HashMap();
    buildGraphMapping(mapping, grappaPanel.getSubgraph());
    modelContainer = new JScrollPane(grappaPanel);
    centerPanel.setLayout(new BorderLayout());
    centerPanel.add(modelContainer, BorderLayout.CENTER);

    //initialize the colored panels
    Color tCol = (Color) levelColors.get(0);
    lowPanel.setBackground(tCol);
    lowPanel.setBorder(BorderFactory.createEtchedBorder());
    lowPanel.setPreferredSize(new Dimension(25, 12));
    tCol = (Color) levelColors.get(1);
    mediumPanel.setBackground(tCol);
    mediumPanel.setBorder(BorderFactory.createEtchedBorder());
    mediumPanel.setPreferredSize(new Dimension(25, 12));
    tCol = (Color) levelColors.get(2);
    highPanel.setBackground(tCol);
    highPanel.setBorder(BorderFactory.createEtchedBorder());
    highPanel.setPreferredSize(new Dimension(25, 12));

    //initialize the levelPanel (which contains the waiting time settings)
    levelPanel.setBorder(BorderFactory.createRaisedBevelBorder());
    levelPanel.setLayout(new GridBagLayout());
    cons.gridx = 0;
    cons.gridy = 0;
    cons.gridwidth = 2;
    cons.insets = new Insets(2, 2, 0, 5);
    cons.weightx = 0;
    levelPanel.add(waitingLabel, cons);
    cons.gridx = 0;
    cons.gridy = 1;
    cons.anchor = GridBagConstraints.WEST;
    cons.insets = new Insets(2, 2, 0, 5);
    cons.gridwidth = 1;
    levelPanel.add(highPanel, cons);
    cons.gridx = 1;
    cons.gridy = 1;
    levelPanel.add(highLabel, cons);
    cons.gridx = 0;
    cons.gridy = 2;
    cons.insets = new Insets(1, 2, 0, 5);
    levelPanel.add(mediumPanel, cons);
    cons.gridx = 1;
    cons.gridy = 2;
    levelPanel.add(mediumLabel, cons);
    cons.gridx = 0;
    cons.gridy = 3;
    cons.insets = new Insets(2, 2, 2, 5);
    levelPanel.add(lowPanel, cons);
    cons.gridx = 1;
    cons.gridy = 3;
    levelPanel.add(lowLabel, cons);
    cons.gridx = 0;
    cons.gridy = 4;
    cons.gridwidth = 2;
    cons.insets = new Insets(2, 2, 2, 2);
    changeSettingsButton.setMnemonic(KeyEvent.VK_S);
    levelPanel.add(changeSettingsButton, cons);
    levelPanel.setBackground(new Color(220, 220, 220));

    //initialize the selectionPanel (which contains the selected transitions/place)
    initializeSelection();

    //initialize the metricsBottomPanel
    metricsBottomPanel.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.gridx = 0;
    cons.gridy = 0;
    cons.gridwidth = 5;
    cons.anchor = GridBagConstraints.WEST;
    cons.insets = new Insets(1, 2, 5, 0);
    titleLabel.setFont(new Font("SansSerif", Font.BOLD, 14));
    metricsBottomPanel.add(titleLabel, cons);
    cons.gridx = 0;
    cons.gridy = 1;
    cons.gridwidth = 1;
    cons.insets = new Insets(1, 2, 2, 0);
    metricsBottomPanel.add(numberObjectLabel, cons);
    cons.gridx = 1;
    cons.gridy = 1;
    cons.gridwidth = 1;
    freqObjectLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
    metricsBottomPanel.add(freqObjectLabel, cons);
    cons.gridx = 0;
    cons.gridy = 2;
    cons.gridwidth = 1;
    metricsBottomPanel.add(arrivalPlaceLabel, cons);
    cons.gridx = 1;
    cons.gridy = 2;
    cons.gridwidth = 1;
    ratePlaceLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
    metricsBottomPanel.add(ratePlaceLabel, cons);
    cons.gridx = 0;
    cons.gridy = 3;
    cons.gridwidth = 5;
    metricsBottomPanel.add(tablePanel, cons);
    cons.gridx = 0;
    cons.gridy = 4;
    cons.gridwidth = 2;
    changePercentagesButton.setPreferredSize(new Dimension(170, 25));
    metricsBottomPanel.add(changePercentagesButton, cons);
    cons.gridx = 2;
    cons.gridy = 4;
    cons.gridwidth = 2;
    metricsBottomPanel.add(exportButton, cons);
    //hide all place/transition metrics
    hideAllMetrics();
    metricsBottomContainer = new JScrollPane(metricsBottomPanel);
    metricsBottomContainer.setPreferredSize(new Dimension(550, 140));
    metricsBottomContainer.setMinimumSize(new Dimension(550, 140));
    metricsBottomContainer.setMaximumSize(new Dimension(550, 800));
    metricsBottomContainer.setBorder(BorderFactory.createEmptyBorder());

    //initialize the bottomPanel
    bottomPanel.setBorder(BorderFactory.createEtchedBorder());
    bottomPanel.setPreferredSize(new Dimension(650, 143));
    bottomPanel.setMinimumSize(new Dimension(650, 143));
    bottomPanel.setLayout(new GridBagLayout());
    GridBagConstraints con = new GridBagConstraints();
    con.gridx = 0;
    con.gridy = 0;
    con.gridwidth = 4;
    con.weightx = 2;
    bottomPanel.add(metricsBottomContainer, con);
    con.gridx = 4;
    con.gridy = 0;
    con.gridwidth = 1;
    con.weightx = 1;
    con.anchor = GridBagConstraints.EAST;
    bottomPanel.add(levelPanel, con);
    con.gridx = 5;
    con.gridy = 0; //con.gridwidth = 2;
    con.weightx = 1;
    con.anchor = GridBagConstraints.EAST;
    bottomPanel.add(selectionPanel, con);
    //Divide the upper panels by using splitPanes
    leftSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, westPanel, centerPanel);
    leftSplitPane.setDividerLocation(130);
    leftSplitPane.setOneTouchExpandable(true);
    rightSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSplitPane, processContainer);
    rightSplitPane.setDividerLocation(rightSplitPane.getSize().width - rightSplitPane.getInsets().right
            - rightSplitPane.getDividerSize() - 240); //processContainer.getWidth());
    rightSplitPane.setOneTouchExpandable(true);
    rightSplitPane.setResizeWeight(1.0);
    rightSplitPane.setDividerSize(3);

    //set tooltips
    processTable.setToolTipText("Throughput time of the process, based on" + " the selected cases");
    rateProcessLabel.setToolTipText("Arrival rate of the selected cases");
    arrivalProcessLabel.setToolTipText("Arrival rate of the selected cases");
    completedLabel.setToolTipText(
            "Total number of the selected cases that" + "  have completed properly and successfully");
    properLabel.setToolTipText(
            "Total number of the selected cases that" + " have completed properly and successfully");
    casesProcessLabel.setToolTipText("Total number of cases selected in" + " the table on the left");
    numberProcessLabel.setToolTipText("Total number of cases selected in" + " the table on the left");
    changeSettingsButton.setToolTipText("Adjust the current waiting time" + " classifications");
    placeTable.setToolTipText("Time-metrics of the selected place, based on" + " the selected cases");
    transitionTable.setToolTipText(
            "Time cases spend in between the" + " selected transitions, based on the selected cases");
    activityTable.setToolTipText(
            "Time-metrics of activity related to the" + " selected transition, based on the selected cases");
    processInstanceIDsTable.setToolTipText("Selected cases");
    changePercentagesButton.setToolTipText("Change percentages of slow," + " fast and normal");
    changeProcessPercButton.setToolTipText("Change percentages of slow," + " fast and normal");
    exportButton.setToolTipText("Export the values of all measurements of"
            + " the metrics in the table above to a comma-seperated" + " text-file");
    exportProcessButton.setToolTipText("Export the value of the throughput"
            + " time of all selected process instances to a comma-seperated" + " text-file");
    //initialize the performanceAnalysisGUI
    this.setLayout(new BorderLayout());
    this.add(bottomPanel, BorderLayout.SOUTH);
    this.add(rightSplitPane, BorderLayout.CENTER);
    this.validate();
    this.repaint();
}

From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java

/**
 * Singleton pattern : private constructor Use instead.
 *//*  w w  w.  j ava2  s.c  o  m*/
private MMMainFrame() {
    super(NODE_NAME, false, true, false, true);
    instancing = true;
    // --------------
    // INITIALIZATION
    // --------------
    _sysConfigFile = "";
    _isConfigLoaded = false;
    _root = PluginPreferences.getPreferences().node(NODE_NAME);
    final MainFrame mainFrame = Icy.getMainInterface().getMainFrame();

    // --------------
    // PROGRESS FRAME
    // --------------
    ThreadUtil.invokeLater(new Runnable() {
        @Override
        public void run() {
            _progressFrame = new IcyFrame("", false, false, false, false);
            _progressBar = new JProgressBar();
            _progressBar.setString("Please wait while loading...");
            _progressBar.setStringPainted(true);
            _progressBar.setIndeterminate(true);
            _progressBar.setMinimum(0);
            _progressBar.setMaximum(1000);
            _progressBar.setBounds(50, 50, 100, 30);
            _progressFrame.setSize(300, 100);
            _progressFrame.setResizable(false);
            _progressFrame.add(_progressBar);
            _progressFrame.addToMainDesktopPane();
            loadConfig(true);
            if (_sysConfigFile == "") {
                instancing = false;
                return;
            }
            ThreadUtil.bgRun(new Runnable() {

                @Override
                public void run() {
                    while (!_isConfigLoaded) {
                        if (!instancing)
                            return;
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException e) {
                        }
                    }
                    ThreadUtil.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            // --------------------
                            // START INITIALIZATION
                            // --------------------
                            if (_progressBar != null)
                                getContentPane().remove(_progressBar);
                            if (mCore == null) {
                                close();
                                return;
                            }

                            // ReportingUtils.setCore(mCore);
                            _afMgr = new AutofocusManager(MMMainFrame.this);
                            acqMgr = new AcquisitionManager();
                            PositionList posList = new PositionList();

                            _camera_label = MMCoreJ.getG_Keyword_CameraName();
                            if (_camera_label == null)
                                _camera_label = "";
                            try {
                                setPositionList(posList);
                            } catch (MMScriptException e1) {
                                e1.printStackTrace();
                            }
                            posListDlg_ = new PositionListDlg(mCore, MMMainFrame.this, _posList, null, dlg);
                            posListDlg_.setModalityType(ModalityType.APPLICATION_MODAL);

                            callback = new EventCallBackManager();
                            mCore.registerCallback(callback);

                            engine_ = new AcquisitionWrapperEngineIcy();
                            engine_.setParentGUI(MMMainFrame.this);
                            engine_.setCore(mCore, getAutofocusManager());
                            engine_.setPositionList(getPositionList());

                            setSystemMenuCallback(new MenuCallback() {

                                @Override
                                public JMenu getMenu() {
                                    JMenu toReturn = MMMainFrame.this.getDefaultSystemMenu();
                                    JMenuItem hconfig = new JMenuItem("Configuration Wizard");
                                    hconfig.setIcon(new IcyIcon("cog", MENU_ICON_SIZE));

                                    hconfig.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            if (!_pluginListEmpty && !ConfirmDialog.confirm("Are you sure ?",
                                                    "<html>Loading the Configuration Wizard will unload all the devices and pause all running acquisitions.</br> Are you sure you want to continue ?</html>"))
                                                return;
                                            notifyConfigAboutToChange(null);
                                            try {
                                                mCore.unloadAllDevices();
                                            } catch (Exception e1) {
                                                e1.printStackTrace();
                                            }
                                            String previous_config = _sysConfigFile;
                                            ConfiguratorDlg2 configurator = new ConfiguratorDlg2(mCore,
                                                    _sysConfigFile);
                                            configurator.setVisible(true);
                                            String res = configurator.getFileName();
                                            if (_sysConfigFile == "" || _sysConfigFile == res || res == "") {
                                                _sysConfigFile = previous_config;
                                                loadConfig();
                                            }
                                            refreshGUI();
                                            notifyConfigChanged(null);
                                        }
                                    });

                                    JMenuItem menuPxSizeConfigItem = new JMenuItem("Pixel Size Config");
                                    menuPxSizeConfigItem.setIcon(new IcyIcon("link", MENU_ICON_SIZE));
                                    menuPxSizeConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G,
                                            InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK));
                                    menuPxSizeConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            CalibrationListDlg dlg = new CalibrationListDlg(mCore);
                                            dlg.setDefaultCloseOperation(2);
                                            dlg.setParentGUI(MMMainFrame.this);
                                            dlg.setVisible(true);
                                            dlg.addWindowListener(new WindowAdapter() {
                                                @Override
                                                public void windowClosed(WindowEvent e) {
                                                    super.windowClosed(e);
                                                    notifyConfigChanged(null);
                                                }
                                            });
                                            notifyConfigAboutToChange(null);
                                        }
                                    });

                                    JMenuItem loadConfigItem = new JMenuItem("Load Configuration");
                                    loadConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,
                                            InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK));
                                    loadConfigItem.setIcon(new IcyIcon("folder_open", MENU_ICON_SIZE));
                                    loadConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            loadConfig();
                                            initializeGUI();
                                            refreshGUI();
                                        }
                                    });
                                    JMenuItem saveConfigItem = new JMenuItem("Save Configuration");
                                    saveConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
                                            InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK));
                                    saveConfigItem.setIcon(new IcyIcon("save", MENU_ICON_SIZE));
                                    saveConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            saveConfig();
                                        }
                                    });
                                    JMenuItem advancedConfigItem = new JMenuItem("Advanced Configuration");
                                    advancedConfigItem.setIcon(new IcyIcon("wrench_plus", MENU_ICON_SIZE));
                                    advancedConfigItem.addActionListener(new ActionListener() {

                                        /**
                                         */
                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            new ToolTipFrame(
                                                    "<html><h3>About Advanced Config</h3><p>Advanced Configuration is a tool "
                                                            + "in which you fill some data <br/>about your configuration that some "
                                                            + "plugins may need to access to.<br/> Exemple: the real values of the magnification"
                                                            + "of your objectives.</p></html>",
                                                    "MM4IcyAdvancedConfig");
                                            if (advancedDlg == null)
                                                advancedDlg = new AdvancedConfigurationDialog();
                                            advancedDlg.setVisible(!advancedDlg.isVisible());
                                            advancedDlg.setLocationRelativeTo(mainFrame);
                                        }
                                    });
                                    JMenuItem loadPresetConfigItem = new JMenuItem(
                                            "Load Configuration Presets");
                                    loadPresetConfigItem.setIcon(new IcyIcon("doc_import", MENU_ICON_SIZE));
                                    loadPresetConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            notifyConfigAboutToChange(null);
                                            loadPresets();
                                            notifyConfigChanged(null);
                                        }
                                    });
                                    JMenuItem savePresetConfigItem = new JMenuItem(
                                            "Save Configuration Presets");
                                    savePresetConfigItem.setIcon(new IcyIcon("doc_export", MENU_ICON_SIZE));
                                    savePresetConfigItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            savePresets();
                                        }
                                    });
                                    JMenuItem aboutItem = new JMenuItem("About");
                                    aboutItem.setIcon(new IcyIcon("info", MENU_ICON_SIZE));
                                    aboutItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            final JDialog dialog = new JDialog(mainFrame, "About");
                                            JPanel panel_container = new JPanel();
                                            panel_container
                                                    .setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
                                            JPanel center = new JPanel(new BorderLayout());
                                            final JLabel value = new JLabel("<html><body>"
                                                    + "<h2>About</h2><p>Micro-Manager for Icy is being developed by Thomas Provoost."
                                                    + "<br/>Copyright 2011, Institut Pasteur</p><br/>"
                                                    + "<p>This plugin is based on Micro-Manager v1.4.6. which is developed under the following license:<br/>"
                                                    + "<i>This software is distributed free of charge in the hope that it will be<br/>"
                                                    + "useful, but WITHOUT ANY WARRANTY; without even the implied<br/>"
                                                    + "warranty of merchantability or fitness for a particular purpose. In no<br/>"
                                                    + "event shall the copyright owner or contributors be liable for any direct,<br/>"
                                                    + "indirect, incidental spacial, examplary, or consequential damages.<br/>"
                                                    + "Copyright University of California San Francisco, 2007, 2008, 2009,<br/>"
                                                    + "2010. All rights reserved.</i>" + "</p>"
                                                    + "</body></html>");
                                            JLabel link = new JLabel(
                                                    "<html><a href=\"\">For more information, please follow this link.</a></html>");
                                            link.addMouseListener(new MouseAdapter() {
                                                @Override
                                                public void mousePressed(MouseEvent mouseevent) {
                                                    NetworkUtil.openBrowser(
                                                            "http://valelab.ucsf.edu/~MM/MMwiki/index.php/Micro-Manager");
                                                }
                                            });
                                            value.setSize(new Dimension(50, 18));
                                            value.setAlignmentX(SwingConstants.HORIZONTAL);
                                            value.setBorder(BorderFactory.createEmptyBorder(0, 0, 20, 0));

                                            center.add(value, BorderLayout.CENTER);
                                            center.add(link, BorderLayout.SOUTH);

                                            JPanel panel_south = new JPanel();
                                            panel_south.setLayout(new BoxLayout(panel_south, BoxLayout.X_AXIS));
                                            JButton btn = new JButton("OK");
                                            btn.addActionListener(new ActionListener() {

                                                @Override
                                                public void actionPerformed(ActionEvent actionevent) {
                                                    dialog.dispose();
                                                }
                                            });
                                            panel_south.add(Box.createHorizontalGlue());
                                            panel_south.add(btn);
                                            panel_south.add(Box.createHorizontalGlue());

                                            dialog.setLayout(new BorderLayout());
                                            panel_container.setLayout(new BorderLayout());
                                            panel_container.add(center, BorderLayout.CENTER);
                                            panel_container.add(panel_south, BorderLayout.SOUTH);
                                            dialog.add(panel_container, BorderLayout.CENTER);
                                            dialog.setResizable(false);
                                            dialog.setVisible(true);
                                            dialog.pack();
                                            dialog.setLocation(
                                                    (int) mainFrame.getSize().getWidth() / 2
                                                            - dialog.getWidth() / 2,
                                                    (int) mainFrame.getSize().getHeight() / 2
                                                            - dialog.getHeight() / 2);
                                            dialog.setLocationRelativeTo(mainFrame);
                                        }
                                    });
                                    JMenuItem propertyBrowserItem = new JMenuItem("Property Browser");
                                    propertyBrowserItem.setAccelerator(
                                            KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, SHORTCUTKEY_MASK));
                                    propertyBrowserItem.setIcon(new IcyIcon("db", MENU_ICON_SIZE));
                                    propertyBrowserItem.addActionListener(new ActionListener() {

                                        @Override
                                        public void actionPerformed(ActionEvent e) {
                                            editor.setVisible(!editor.isVisible());
                                        }
                                    });
                                    int idx = 0;
                                    toReturn.insert(hconfig, idx++);
                                    toReturn.insert(loadConfigItem, idx++);
                                    toReturn.insert(saveConfigItem, idx++);
                                    toReturn.insert(advancedConfigItem, idx++);
                                    toReturn.insertSeparator(idx++);
                                    toReturn.insert(loadPresetConfigItem, idx++);
                                    toReturn.insert(savePresetConfigItem, idx++);
                                    toReturn.insertSeparator(idx++);
                                    toReturn.insert(propertyBrowserItem, idx++);
                                    toReturn.insert(menuPxSizeConfigItem, idx++);
                                    toReturn.insertSeparator(idx++);
                                    toReturn.insert(aboutItem, idx++);
                                    return toReturn;
                                }
                            });

                            saveConfigButton_ = new JButton("Save Button");

                            // SETUP
                            _groupPad = new ConfigGroupPad();
                            _groupPad.setParentGUI(MMMainFrame.this);
                            _groupPad.setFont(new Font("", 0, 10));
                            _groupPad.setCore(mCore);
                            _groupPad.setParentGUI(MMMainFrame.this);
                            _groupButtonsPanel = new ConfigButtonsPanel();
                            _groupButtonsPanel.setCore(mCore);
                            _groupButtonsPanel.setGUI(MMMainFrame.this);
                            _groupButtonsPanel.setConfigPad(_groupPad);

                            // LEFT PART OF INTERFACE
                            _panelConfig = new JPanel();
                            _panelConfig.setLayout(new BoxLayout(_panelConfig, BoxLayout.Y_AXIS));
                            _panelConfig.add(_groupPad, BorderLayout.CENTER);
                            _panelConfig.add(_groupButtonsPanel, BorderLayout.SOUTH);
                            _panelConfig.setPreferredSize(new Dimension(300, 300));

                            // MIDDLE PART OF INTERFACE
                            _panel_cameraSettings = new JPanel();
                            _panel_cameraSettings.setLayout(new GridLayout(5, 2));
                            _panel_cameraSettings.setMinimumSize(new Dimension(100, 200));

                            _txtExposure = new JTextField();
                            try {
                                mCore.setExposure(90.0D);
                                _txtExposure.setText(String.valueOf(mCore.getExposure()));
                            } catch (Exception e2) {
                                _txtExposure.setText("90");
                            }
                            _txtExposure.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20));
                            _txtExposure.addKeyListener(new KeyAdapter() {
                                @Override
                                public void keyPressed(KeyEvent keyevent) {
                                    if (keyevent.getKeyCode() == KeyEvent.VK_ENTER)
                                        setExposure();
                                }
                            });
                            _panel_cameraSettings.add(new JLabel("Exposure [ms]: "));
                            _panel_cameraSettings.add(_txtExposure);

                            _combo_binning = new JComboBox();
                            _combo_binning.setMaximumRowCount(4);
                            _combo_binning.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
                            _combo_binning.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    changeBinning();
                                }
                            });

                            _panel_cameraSettings.add(new JLabel("Binning: "));
                            _panel_cameraSettings.add(_combo_binning);

                            _combo_shutters = new JComboBox();
                            _combo_shutters.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent arg0) {
                                    try {
                                        if (_combo_shutters.getSelectedItem() != null) {
                                            mCore.setShutterDevice((String) _combo_shutters.getSelectedItem());
                                            _prefs.put(PREF_SHUTTER, (String) _combo_shutters
                                                    .getItemAt(_combo_shutters.getSelectedIndex()));
                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            });
                            _combo_shutters.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
                            _panel_cameraSettings.add(new JLabel("Shutter : "));
                            _panel_cameraSettings.add(_combo_shutters);

                            ActionListener action_listener = new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    updateHistogram();
                                }
                            };

                            _cbAbsoluteHisto = new JCheckBox();
                            _cbAbsoluteHisto.addActionListener(action_listener);
                            _cbAbsoluteHisto.addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent actionevent) {
                                    _comboBitDepth.setEnabled(_cbAbsoluteHisto.isSelected());
                                    _prefs.putBoolean(PREF_ABS_HIST, _cbAbsoluteHisto.isSelected());
                                }
                            });
                            _panel_cameraSettings.add(new JLabel("Display absolute histogram ?"));
                            _panel_cameraSettings.add(_cbAbsoluteHisto);

                            _comboBitDepth = new JComboBox(new String[] { "8-bit", "9-bit", "10-bit", "11-bit",
                                    "12-bit", "13-bit", "14-bit", "15-bit", "16-bit" });
                            _comboBitDepth.addActionListener(action_listener);
                            _comboBitDepth.addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent actionevent) {
                                    _prefs.putInt(PREF_BITDEPTH, _comboBitDepth.getSelectedIndex());
                                }
                            });
                            _comboBitDepth.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20));
                            _comboBitDepth.setEnabled(false);
                            _panel_cameraSettings.add(new JLabel("Select your bit depth for abs. hitogram: "));
                            _panel_cameraSettings.add(_comboBitDepth);

                            // Acquisition
                            _panelAcquisitions = new JPanel();
                            _panelAcquisitions.setLayout(new BoxLayout(_panelAcquisitions, BoxLayout.Y_AXIS));

                            // Color settings
                            _panelColorChooser = new JPanel();
                            _panelColorChooser.setLayout(new BoxLayout(_panelColorChooser, BoxLayout.Y_AXIS));
                            painterPreferences = MicroscopePainterPreferences.getInstance();
                            painterPreferences.setPreferences(_prefs.node("paintersPreferences"));
                            painterPreferences.loadColors();

                            HashMap<String, Color> allColors = painterPreferences.getColors();
                            String[] allKeys = (String[]) allColors.keySet().toArray(new String[0]);
                            String[] columnNames = { "Painter", "Color", "Transparency" };
                            Object[][] data = new Object[allKeys.length][3];

                            for (int i = 0; i < allKeys.length; ++i) {
                                final int actualRow = i;
                                String actualKey = allKeys[i].toString();
                                data[i][0] = actualKey;
                                data[i][1] = allColors.get(actualKey);
                                final JSlider slider = new JSlider(0, 255, allColors.get(actualKey).getAlpha());
                                slider.addChangeListener(new ChangeListener() {

                                    @Override
                                    public void stateChanged(ChangeEvent changeevent) {
                                        painterTable.setValueAt(slider, actualRow, 2);
                                    }
                                });
                                data[i][2] = slider;
                            }
                            final AbstractTableModel tableModel = new JTableEvolvedModel(columnNames, data);
                            painterTable = new JTable(tableModel);
                            painterTable.getModel().addTableModelListener(new TableModelListener() {

                                @Override
                                public void tableChanged(TableModelEvent tablemodelevent) {
                                    if (tablemodelevent.getType() == TableModelEvent.UPDATE) {
                                        int row = tablemodelevent.getFirstRow();
                                        int col = tablemodelevent.getColumn();
                                        String columnName = tableModel.getColumnName(col);
                                        String painterName = (String) tableModel.getValueAt(row, 0);
                                        if (columnName.contains("Color")) {
                                            // New color value
                                            int alpha = painterPreferences.getColor(painterName).getAlpha();
                                            Color coloNew = (Color) tableModel.getValueAt(row, 1);
                                            painterPreferences.setColor(painterName, new Color(coloNew.getRed(),
                                                    coloNew.getGreen(), coloNew.getBlue(), alpha));
                                        } else if (columnName.contains("Transparency")) {
                                            // New alpha value
                                            Color c = painterPreferences.getColor(painterName);
                                            int alphaValue = ((JSlider) tableModel.getValueAt(row, 2))
                                                    .getValue();
                                            painterPreferences.setColor(painterName, new Color(c.getRed(),
                                                    c.getGreen(), c.getBlue(), alphaValue));
                                        }
                                        /*
                                         * for (int i = 0; i <
                                         * tableModel.getRowCount(); ++i) { try {
                                         * String painterName = (String)
                                         * tableModel.getValueAt(i, 0); Color c =
                                         * (Color) tableModel.getValueAt(i, 1); int
                                         * alphaValue; if (ASpinnerChanged &&
                                         * tablemodelevent.getFirstRow() == i) {
                                         * alphaValue = ((JSlider)
                                         * tableModel.getValueAt(i, 2)).getValue();
                                         * } else { alphaValue =
                                         * painterPreferences.getColor
                                         * (painterPreferences
                                         * .getPainterName(i)).getAlpha(); }
                                         * painterPreferences.setColor(painterName,
                                         * new Color(c.getRed(), c.getGreen(),
                                         * c.getBlue(), alphaValue)); } catch
                                         * (Exception e) { System.out.println(
                                         * "error with painter table update"); } }
                                         */
                                    }
                                }
                            });
                            painterTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
                            painterTable.setFillsViewportHeight(true);

                            // Create the scroll pane and add the table to it.
                            JScrollPane scrollPane = new JScrollPane(painterTable);

                            // Set up renderer and editor for the Favorite Color
                            // column.
                            painterTable.setDefaultRenderer(Color.class, new ColorRenderer(true));
                            painterTable.setDefaultEditor(Color.class, new ColorEditor());

                            painterTable.setDefaultRenderer(JSlider.class, new SliderRenderer(0, 255));
                            painterTable.setDefaultEditor(JSlider.class, new SliderEditor());

                            _panelColorChooser.add(scrollPane);
                            _panelColorChooser.add(Box.createVerticalGlue());

                            _mainPanel = new JPanel();
                            _mainPanel.setLayout(new BorderLayout());

                            // EDITOR
                            // will refresh the data and verify if any change
                            // occurs.
                            // editor = new PropertyEditor(MMMainFrame.this);
                            // editor.setCore(mCore);
                            // editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
                            // editor.addToMainDesktopPane();
                            // editor.refresh();
                            // editor.start();

                            editor = new PropertyEditor();
                            editor.setGui(MMMainFrame.this);
                            editor.setCore(mCore);
                            editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
                            // editor.addToMainDesktopPane();
                            // editor.refresh();
                            // editor.start();

                            add(_mainPanel);
                            initializeGUI();
                            loadPreferences();
                            refreshGUI();
                            setResizable(true);
                            addToMainDesktopPane();
                            instanced = true;
                            instancing = false;
                            _singleton = MMMainFrame.this;
                            setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                            addFrameListener(new IcyFrameAdapter() {
                                @Override
                                public void icyFrameClosing(IcyFrameEvent e) {
                                    customClose();
                                }
                            });
                            acceptListener = new AcceptListener() {

                                @Override
                                public boolean accept(Object source) {
                                    close();
                                    return _pluginListEmpty;
                                }
                            };

                            adapter = new MainAdapter() {

                                @Override
                                public void sequenceOpened(MainEvent event) {
                                    updateHistogram();
                                }

                            };
                            Icy.getMainInterface().addCanExitListener(acceptListener);
                            Icy.getMainInterface().addListener(adapter);
                        }
                    });
                }
            });
        }
    });
}

From source file:org.processmining.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Actually builds the UI//w  w w. ja va  2 s . c om
 * 
 * @throws Exception
 */
private void jbInit() throws Exception {
    // Initialize the table which contains the log traces
    processInstanceIDsTable = new DoubleClickTable(new ExtendedLogTable(), updateButton);
    // select all rows as at the beginning the results count for the whole
    // log
    processInstanceIDsTable.getSelectionModel().addSelectionInterval(0, extendedLog.getSizeOfLog() - 1);

    tableContainer = new JScrollPane(processInstanceIDsTable);

    // initialize the westPanel (which contains the processInstanceIDsTable)
    westPanel.setPreferredSize(new Dimension(100, 300));
    westPanel.setLayout(new BorderLayout());
    westPanel.add(tableContainer, BorderLayout.CENTER);
    updateButton.setToolTipText("Update metrics to the selected process instances");
    westPanel.add(piButtonsPanel, BorderLayout.SOUTH);
    piButtonsPanel.setLayout(new BorderLayout());
    piButtonsPanel.add(updateButton, BorderLayout.CENTER);
    piButtonsPanel.add(invertButton, BorderLayout.SOUTH);

    // initialize the eastpanel (which contains the process-metrics)
    eastPanel.setPreferredSize(new Dimension(240, 390));
    eastPanel.setMinimumSize(new Dimension(240, 390));
    eastPanel.setLayout(new GridBagLayout());
    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = 0;
    cons.gridy = 0;
    cons.insets = new Insets(0, 5, 5, 0);
    cons.anchor = GridBagConstraints.WEST;
    processLabel.setFont(new Font("SansSerif", Font.BOLD, 16));
    eastPanel.add(processLabel, cons);
    cons.gridx = 0;
    cons.gridy = 1;
    cons.insets = new Insets(8, 8, 0, 0);
    eastPanel.add(numberProcessLabel, cons);
    casesProcessLabel.setText(extendedLog.getSizeOfLog() + " cases");
    casesProcessLabel.setFont(new Font("SansSerif", Font.PLAIN, 11));
    cons.gridx = 0;
    cons.gridy = 2;
    eastPanel.add(casesProcessLabel, cons);
    cons.gridx = 0;
    cons.gridy = 3;
    eastPanel.add(properLabel, cons);
    completedLabel.setFont(new Font("SansSerif", Font.PLAIN, 11));
    cons.gridx = 0;
    cons.gridy = 4;
    eastPanel.add(completedLabel, cons);
    cons.gridx = 0;
    cons.gridy = 5;
    eastPanel.add(arrivalProcessLabel, cons);
    rateProcessLabel.setFont(new Font("SansSerif", Font.PLAIN, 11));
    cons.gridx = 0;
    cons.gridy = 6;
    eastPanel.add(rateProcessLabel, cons);
    cons.gridx = 0;
    cons.gridy = 7;
    cons.gridwidth = 2;
    cons.insets = new Insets(15, 5, 0, 2);
    cons.ipadx = 300;
    eastPanel.add(processTablePanel, cons);
    cons.gridx = 0;
    cons.gridy = 8;
    cons.gridwidth = 1;
    cons.insets = new Insets(0, 5, 0, 0);
    cons.weightx = 1;
    cons.ipadx = 0;
    exportProcessButton.setPreferredSize(new Dimension(110, 42));
    exportProcessButton.setMaximumSize(new Dimension(110, 42));
    changeProcessPercButton.setPreferredSize(new Dimension(110, 42));
    changeProcessPercButton.setMaximumSize(new Dimension(110, 42));
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.setPreferredSize(new Dimension(240, 42));
    buttonPanel.add(changeProcessPercButton);
    buttonPanel.add(exportProcessButton);
    eastPanel.add(buttonPanel, cons);

    processContainer = new JScrollPane(eastPanel);
    processContainer.setPreferredSize(new Dimension(240, 390));
    // initialize the processTablePanel (which contains the table with
    // throughput times)
    processTablePanel.setLayout(new BorderLayout());
    processTablePanel.setMinimumSize(new Dimension(240, 130));
    processTablePanel.setPreferredSize(new Dimension(240, 130));
    processTable.setRowSelectionAllowed(false);
    processTablePanel.add(processTable.getTableHeader(), BorderLayout.PAGE_START);
    processTablePanel.add(processTable, BorderLayout.CENTER);

    // initialize the grappaPanel (which contains the Petri net UI) and
    // place
    // it on the centerPanel
    grappaPanel = replayResult.getVisualization(extendedLog.getLogTraceIDs());
    grappaPanel.addGrappaListener(new ExtendedGrappaAdapter());
    mapping = new HashMap();
    buildGraphMapping(mapping, grappaPanel.getSubgraph());
    modelContainer = new JScrollPane(grappaPanel);
    centerPanel.setLayout(new BorderLayout());
    centerPanel.add(modelContainer, BorderLayout.CENTER);

    // initialize the colored panels
    Color tCol = (Color) levelColors.get(0);
    lowPanel.setBackground(tCol);
    lowPanel.setBorder(BorderFactory.createEtchedBorder());
    lowPanel.setPreferredSize(new Dimension(25, 12));
    tCol = (Color) levelColors.get(1);
    mediumPanel.setBackground(tCol);
    mediumPanel.setBorder(BorderFactory.createEtchedBorder());
    mediumPanel.setPreferredSize(new Dimension(25, 12));
    tCol = (Color) levelColors.get(2);
    highPanel.setBackground(tCol);
    highPanel.setBorder(BorderFactory.createEtchedBorder());
    highPanel.setPreferredSize(new Dimension(25, 12));

    // initialize the levelPanel (which contains the waiting time settings)
    levelPanel.setBorder(BorderFactory.createRaisedBevelBorder());
    levelPanel.setLayout(new GridBagLayout());
    cons.gridx = 0;
    cons.gridy = 0;
    cons.gridwidth = 2;
    cons.insets = new Insets(2, 2, 0, 5);
    cons.weightx = 0;
    levelPanel.add(waitingLabel, cons);
    cons.gridx = 0;
    cons.gridy = 1;
    cons.anchor = GridBagConstraints.WEST;
    cons.insets = new Insets(2, 2, 0, 5);
    cons.gridwidth = 1;
    levelPanel.add(highPanel, cons);
    cons.gridx = 1;
    cons.gridy = 1;
    levelPanel.add(highLabel, cons);
    cons.gridx = 0;
    cons.gridy = 2;
    cons.insets = new Insets(1, 2, 0, 5);
    levelPanel.add(mediumPanel, cons);
    cons.gridx = 1;
    cons.gridy = 2;
    levelPanel.add(mediumLabel, cons);
    cons.gridx = 0;
    cons.gridy = 3;
    cons.insets = new Insets(2, 2, 2, 5);
    levelPanel.add(lowPanel, cons);
    cons.gridx = 1;
    cons.gridy = 3;
    levelPanel.add(lowLabel, cons);
    cons.gridx = 0;
    cons.gridy = 4;
    cons.gridwidth = 2;
    cons.insets = new Insets(2, 2, 2, 2);
    changeSettingsButton.setMnemonic(KeyEvent.VK_S);
    levelPanel.add(changeSettingsButton, cons);
    levelPanel.setBackground(new Color(220, 220, 220));

    // initialize the selectionPanel (which contains the selected
    // transitions/place)
    initializeSelection();

    // initialize the metricsBottomPanel
    metricsBottomPanel.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.gridx = 0;
    cons.gridy = 0;
    cons.gridwidth = 5;
    cons.anchor = GridBagConstraints.WEST;
    cons.insets = new Insets(1, 2, 5, 0);
    titleLabel.setFont(new Font("SansSerif", Font.BOLD, 14));
    metricsBottomPanel.add(titleLabel, cons);
    cons.gridx = 0;
    cons.gridy = 1;
    cons.gridwidth = 1;
    cons.insets = new Insets(1, 2, 2, 0);
    metricsBottomPanel.add(numberObjectLabel, cons);
    cons.gridx = 1;
    cons.gridy = 1;
    cons.gridwidth = 1;
    freqObjectLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
    metricsBottomPanel.add(freqObjectLabel, cons);
    cons.gridx = 0;
    cons.gridy = 2;
    cons.gridwidth = 1;
    metricsBottomPanel.add(arrivalPlaceLabel, cons);
    cons.gridx = 1;
    cons.gridy = 2;
    cons.gridwidth = 1;
    ratePlaceLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
    metricsBottomPanel.add(ratePlaceLabel, cons);
    cons.gridx = 0;
    cons.gridy = 3;
    cons.gridwidth = 5;
    metricsBottomPanel.add(tablePanel, cons);
    cons.gridx = 0;
    cons.gridy = 4;
    cons.gridwidth = 2;
    changePercentagesButton.setPreferredSize(new Dimension(170, 25));
    metricsBottomPanel.add(changePercentagesButton, cons);
    cons.gridx = 2;
    cons.gridy = 4;
    cons.gridwidth = 2;
    metricsBottomPanel.add(exportButton, cons);
    // hide all place/transition metrics
    hideAllMetrics();
    metricsBottomContainer = new JScrollPane(metricsBottomPanel);
    metricsBottomContainer.setPreferredSize(new Dimension(550, 140));
    metricsBottomContainer.setMinimumSize(new Dimension(550, 140));
    metricsBottomContainer.setMaximumSize(new Dimension(550, 800));
    metricsBottomContainer.setBorder(BorderFactory.createEmptyBorder());

    // initialize the bottomPanel
    bottomPanel.setBorder(BorderFactory.createEtchedBorder());
    bottomPanel.setPreferredSize(new Dimension(650, 143));
    bottomPanel.setMinimumSize(new Dimension(650, 143));
    bottomPanel.setLayout(new GridBagLayout());
    GridBagConstraints con = new GridBagConstraints();
    con.gridx = 0;
    con.gridy = 0;
    con.gridwidth = 4;
    con.weightx = 2;
    bottomPanel.add(metricsBottomContainer, con);
    con.gridx = 4;
    con.gridy = 0;
    con.gridwidth = 1;
    con.weightx = 1;
    con.anchor = GridBagConstraints.EAST;
    bottomPanel.add(levelPanel, con);
    con.gridx = 5;
    con.gridy = 0; // con.gridwidth = 2;
    con.weightx = 1;
    con.anchor = GridBagConstraints.EAST;
    bottomPanel.add(selectionPanel, con);
    // Divide the upper panels by using splitPanes
    leftSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, westPanel, centerPanel);
    leftSplitPane.setDividerLocation(130);
    leftSplitPane.setOneTouchExpandable(true);
    rightSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSplitPane, processContainer);
    rightSplitPane.setDividerLocation(rightSplitPane.getSize().width - rightSplitPane.getInsets().right
            - rightSplitPane.getDividerSize() - 240); // processContainer.getWidth());
    rightSplitPane.setOneTouchExpandable(true);
    rightSplitPane.setResizeWeight(1.0);
    rightSplitPane.setDividerSize(3);

    // set tooltips
    processTable.setToolTipText("Throughput time of the process, based on" + " the selected cases");
    rateProcessLabel.setToolTipText("Arrival rate of the selected cases");
    arrivalProcessLabel.setToolTipText("Arrival rate of the selected cases");
    completedLabel.setToolTipText(
            "Total number of the selected cases that" + "  have completed properly and successfully");
    properLabel.setToolTipText(
            "Total number of the selected cases that" + " have completed properly and successfully");
    casesProcessLabel.setToolTipText("Total number of cases selected in" + " the table on the left");
    numberProcessLabel.setToolTipText("Total number of cases selected in" + " the table on the left");
    changeSettingsButton.setToolTipText("Adjust the current waiting time" + " classifications");
    placeTable.setToolTipText("Time-metrics of the selected place, based on" + " the selected cases");
    transitionTable.setToolTipText(
            "Time cases spend in between the" + " selected transitions, based on the selected cases");
    activityTable.setToolTipText(
            "Time-metrics of activity related to the" + " selected transition, based on the selected cases");
    processInstanceIDsTable.setToolTipText("Selected cases");
    changePercentagesButton.setToolTipText("Change percentages of slow," + " fast and normal");
    changeProcessPercButton.setToolTipText("Change percentages of slow," + " fast and normal");
    exportButton.setToolTipText("Export the values of all measurements of"
            + " the metrics in the table above to a comma-seperated" + " text-file");
    exportProcessButton.setToolTipText("Export the value of the throughput"
            + " time of all selected process instances to a comma-seperated" + " text-file");
    // initialize the performanceAnalysisGUI
    this.setLayout(new BorderLayout());
    this.add(bottomPanel, BorderLayout.SOUTH);
    this.add(rightSplitPane, BorderLayout.CENTER);
    this.validate();
    this.repaint();
}

From source file:org.tinymediamanager.ui.movies.MoviePanel.java

private void buildMenu() {
    menu.setMnemonic(KeyEvent.VK_M);

    // menu items
    JMenuItem menuItem = menu.add(actionUpdateDataSources2);
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(//w w w. j a va2 s.  c o m
            KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    final JMenu menuUpdateDatasources = new JMenu(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    final JMenu menuFindMissingMovies = new JMenu(BUNDLE.getString("movie.findmissing")); //$NON-NLS-1$
    menuUpdateDatasources.addMenuListener(new MenuListener() {
        @Override
        public void menuCanceled(MenuEvent arg0) {
        }

        @Override
        public void menuDeselected(MenuEvent arg0) {
        }

        @Override
        public void menuSelected(MenuEvent arg0) {
            menuUpdateDatasources.removeAll();
            menuFindMissingMovies.removeAll();
            for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) {
                JMenuItem item = new JMenuItem(new MovieUpdateSingleDatasourceAction(ds));
                menuUpdateDatasources.add(item);

                item = new JMenuItem(new MovieFindMissingAction(ds));
                menuFindMissingMovies.add(item);

            }
        }
    });
    menu.add(menuUpdateDatasources);

    menu.add(new MovieFindMissingAction());
    menu.add(menuFindMissingMovies);
    menu.add(new MovieCreateOfflineAction(true));

    menu.addSeparator();

    JMenu menuScrape = new JMenu(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$
    menuScrape.setMnemonic(KeyEvent.VK_S);
    menuItem = menuScrape.add(actionScrape2);
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeSelected);
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeUnscraped);
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeMetadataSelected);
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuScrape.add(actionAssignMovieSets);
    menu.add(menuScrape);

    JMenu menuEdit = new JMenu(BUNDLE.getString("Button.edit")); //$NON-NLS-1$
    menuEdit.setMnemonic(KeyEvent.VK_E);
    menuItem = menuEdit.add(actionEditMovie2);
    menuItem.setMnemonic(KeyEvent.VK_E);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionBatchEdit);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionSetWatchedFlag);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionRename2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionRenamerPreview);
    menuItem.setMnemonic(KeyEvent.VK_P);
    menu.add(menuEdit);

    menuItem = menu.add(actionRewriteNfo);
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem = menu.add(actionTrailerDownload);
    menuItem = menu.add(actionSearchSubtitle);
    menuItem = menu.add(actionDownloadSubtitle);

    menu.addSeparator();
    menuItem = menu.add(actionMediaInformation2);
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionExport);
    menuItem.setMnemonic(KeyEvent.VK_X);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionRemove2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(KeyStroke.getKeyStroke((char) KeyEvent.VK_DELETE));
    menuItem = menu.add(actionDelete2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK));
    menu.addSeparator();
    menuItem = menu.add(actionSyncTrakt);
    menuItem.setMnemonic(KeyEvent.VK_T);
    menuItem = menu.add(actionSyncWatchedTrakt);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem = menu.add(actionSyncSelectedTrakt);

    menu.addSeparator();
    menuItem = menu.add(actionClearImageCache);
    menuItem.setMnemonic(KeyEvent.VK_C);

    // popup menu
    JPopupMenu popupMenu = new JPopupMenu();
    popupMenu.add(actionScrape2);
    popupMenu.add(actionScrapeSelected);
    popupMenu.add(actionScrapeUnscraped);
    popupMenu.add(actionScrapeMetadataSelected);
    popupMenu.add(actionAssignMovieSets);
    popupMenu.addSeparator();
    popupMenu.add(actionEditMovie2);
    popupMenu.add(actionBatchEdit);
    popupMenu.add(actionSetWatchedFlag);
    popupMenu.add(actionRewriteNfo);
    popupMenu.add(actionRename2);
    popupMenu.add(actionRenamerPreview);
    popupMenu.add(actionMediaInformation2);
    popupMenu.add(actionExport);
    popupMenu.add(actionTrailerDownload);
    popupMenu.add(actionSearchSubtitle);
    popupMenu.add(actionDownloadSubtitle);
    popupMenu.addSeparator();
    popupMenu.add(actionSyncTrakt);
    popupMenu.add(actionSyncWatchedTrakt);
    popupMenu.add(actionSyncSelectedTrakt);
    popupMenu.addSeparator();
    popupMenu.add(actionClearImageCache);
    popupMenu.addSeparator();
    popupMenu.add(actionRemove2);
    popupMenu.add(actionDelete2);

    if (Globals.isDebug()) {
        JMenu menuDebug = new JMenu("Debug"); //$NON-NLS-1$
        menuDebug.add(debugDumpMovie);
        menuDebug.addSeparator();
        menuDebug.add(new FakeTmmTaskAction("download", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("download", 10, 10));
        menuDebug.add(new FakeTmmTaskAction("image", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("image", 10, 10));
        menuDebug.add(new FakeTmmTaskAction("unnamed", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("unnamed", 10, 10));
        popupMenu.add(menuDebug);
    }

    MouseListener mouseListener = new MovieTableMouseListener(popupMenu, table);
    table.addMouseListener(mouseListener);
}

From source file:org.f2o.absurdum.puck.gui.PuckFrame.java

/**
 * Instances and shows Puck's main frame.
 *///w  ww . j  a  v a2 s. c  o  m
public PuckFrame() {

    super();

    setLookAndFeel(PuckConfiguration.getInstance().getProperty("look"));

    /*
    LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels();
    for ( int i = 0 ; i < lfs.length ; i++ )
    {
       if ( lfs[i].getName().toLowerCase().contains("nimbus") )
       {
    try 
    {
       UIManager.setLookAndFeel(lfs[i].getClassName());
    } 
    catch (Exception e) //class not found, instantiation exception, etc. (shouldn't happen)
    {
       e.printStackTrace();
    }
            
       }
    }
    */

    setSize(PuckConfiguration.getInstance().getIntegerProperty("windowWidth"),
            PuckConfiguration.getInstance().getIntegerProperty("windowHeight"));
    setLocation(PuckConfiguration.getInstance().getIntegerProperty("windowLocationX"),
            PuckConfiguration.getInstance().getIntegerProperty("windowLocationY"));
    //setSize(600,600);
    if (PuckConfiguration.getInstance().getBooleanProperty("windowMaximized"))
        maximizeIfPossible();
    //setTitle(Messages.getInstance().getMessage("frame.title"));
    refreshTitle();
    left = new JPanel();
    right = new JPanel();
    JScrollPane rightScroll = new JScrollPane(right);
    rightScroll.getVerticalScrollBar().setUnitIncrement(16); //faster scrollbar (by default it was very slow, maybe because component inside is not text component!)
    split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, rightScroll) {
        //dynamic resizing of right panel
        /*
        public void setDividerLocation ( int pixels )
        {
              if ( propPanel != null )
              {
          double rightPartSize = getContentPane().getWidth() - pixels - 15;
          System.out.println("rps=" + rightPartSize);
          System.out.println("mnw=" + this.getMinimumSize().getWidth());
          Dimension propPanSize = propPanel.getSize();
          int propPanHeight = 0;
          if (propPanSize != null) propPanHeight = (int) propPanSize.getHeight();
          //propPanel.revalidate();
          System.out.println("h " + propPanHeight);
          //if ( rightPartSize >= propPanel.getMinimumSize().getWidth() )
             propPanel.setPreferredSize(new Dimension((int)rightPartSize,propPanHeight));
             //propPanel.setMinimumSize(new Dimension((int)rightPartSize,propPanHeight));
             //propPanel.setMaximumSize(new Dimension((int)rightPartSize,propPanHeight));
             //propPanel.setSize(new Dimension((int)rightPartSize,propPanHeight));
             propPanel.revalidate();
              }
              super.setDividerLocation(pixels);
        }
        */

    };
    split.setContinuousLayout(true);
    split.setResizeWeight(0.60);
    final int dividerLoc = PuckConfiguration.getInstance().getIntegerProperty("dividerLocation", 0);

    /*
    SwingUtilities.invokeLater(new Runnable(){
    public void run()
    {
    */

    /*   
    }
    });
    */
    split.setOneTouchExpandable(true);
    getContentPane().add(split);

    System.out.println(Toolkit.getDefaultToolkit().getBestCursorSize(20, 20));
    //it's 32x32. Will have to do it.

    //Image img = Toolkit.getDefaultToolkit().createImage( getClass().getResource("addCursor32.png") );

    //Image img = Toolkit.getDefaultToolkit().createImage("addCursor32.png");

    left.setLayout(new BorderLayout());

    //right.setLayout(new BoxLayout(right,BoxLayout.LINE_AXIS));
    if (PuckConfiguration.getInstance().getBooleanProperty("dynamicFormResizing"))
        right.setLayout(new BorderLayout());
    else
        right.setLayout(new FlowLayout());

    propPanel = new PropertiesPanel();
    right.add(propPanel);

    graphPanel = new GraphEditingPanel(propPanel);
    graphPanel.setGrid(Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue());
    graphPanel.setSnapToGrid(
            Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue());
    propPanel.setGraphEditingPanel(graphPanel);
    tools = new PuckToolBar(graphPanel, propPanel, this);
    left.add(tools, BorderLayout.WEST);
    left.add(graphPanel, BorderLayout.CENTER);

    /*
    Action testAction = 
    new AbstractAction()
    {
       public void actionPerformed ( ActionEvent evt )
       {
          System.out.println("Puck!");
       }
    }
    ;
    testAction.putValue(Action.NAME,"Print Puck");
            
    tools.add(testAction);
    */

    /*
    public void saveChanges ( )
    {
       if ( editingFileName == null )
       {
    //save as... code
       }
       else
       {
    File f = new File(editingFileName);
    try
    {
       Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
       d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d));
       Transformer t = TransformerFactory.newInstance().newTransformer();
       Source s = new DOMSource(d);
       Result r = new StreamResult(f);
       t.transform(s,r);
       editingFileName = f.toString();
       refreshTitle();
    }
    catch ( Exception e )
    {
       JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE);
       e.printStackTrace();
    }
       }
    }
    */

    JMenuBar mainMenuBar = new JMenuBar();
    JMenu fileMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file"));
    fileMenu.setMnemonic(KeyEvent.VK_F);
    saveMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.save"));
    saveMenuItem.setMnemonic(KeyEvent.VK_S);
    saveMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (editingFileName == null)
                JOptionPane.showMessageDialog(PuckFrame.this, "File has no name!", "Whoops!",
                        JOptionPane.ERROR_MESSAGE);
            /*
            File f = new File(editingFileName);
            try
            {
             Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
             d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d));
             Transformer t = TransformerFactory.newInstance().newTransformer();
             Source s = new DOMSource(d);
             Result r = new StreamResult(f);
             t.transform(s,r);
             editingFileName = f.toString();
             refreshTitle();
            }
            catch ( Exception e )
            {
             JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE);
             e.printStackTrace();
            }
            */
            try {
                saveChangesInCurrentFile();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }
        }
    });
    JMenu newMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.new"));
    JMenuItem newBlankMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.new.blank"));
    //newBlankMenuItem.setMnemonic(KeyEvent.VK_N);
    newBlankMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            GraphElementPanel.emptyQueue(); //stop deferred loads
            graphPanel.clear();
            propPanel.clear();
            JSyntaxBSHCodeFrame.closeAllInstances();
            WorldPanel wp = new WorldPanel(graphPanel);
            WorldNode wn = new WorldNode(wp);
            graphPanel.setWorldNode(wn);
            propPanel.show(graphPanel.getWorldNode());
            resetCurrentlyEditingFile();
            refreshTitle();
            //revalidate(); //only since java 1.7
            //invalidate();
            //validate();
            split.revalidate(); //JComponents do have it before java 1.7 (not JFrame)
        }
    });
    newMenu.add(newBlankMenuItem);
    JMenu templateMenus = new WorldTemplateMenuBuilder(this).getMenu();
    if (templateMenus != null) {
        for (int i = 0; i < templateMenus.getItemCount(); i++) {
            if (i == 0)
                newMenu.add(new JSeparator());
            newMenu.add(templateMenus.getItem(i));
        }
    }
    JMenuItem saveAsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.saveas"));
    saveAsMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            /*
            JFileChooser jfc = new JFileChooser(".");
            int opt = jfc.showSaveDialog(PuckFrame.this);
            if ( opt == JFileChooser.APPROVE_OPTION )
            {
             File f = jfc.getSelectedFile();
             try
             {
                Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
                d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d));
                Transformer t = TransformerFactory.newInstance().newTransformer();
                Source s = new DOMSource(d);
                Result r = new StreamResult(f);
                t.transform(s,r);
                editingFileName = f.toString();
                saveMenuItem.setEnabled(true);
                refreshTitle();
             }
             catch ( Exception e )
             {
                JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
             }
            }
            */
            try {
                saveAs();
                saveMenuItem.setEnabled(true);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }
            //saveAs(saveMenuItem);
        }
    });
    JMenuItem openMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.open"));
    openMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            //graphPanel.setVisible(false);
            //propPanel.setVisible(false);

            JFileChooser jfc = new JFileChooser(".");
            jfc.setFileFilter(new FiltroFicheroMundo());
            int opt = jfc.showOpenDialog(PuckFrame.this);
            if (opt == JFileChooser.APPROVE_OPTION) {
                File f = jfc.getSelectedFile();
                openFileOrShowError(f);
            }

            //graphPanel.setVisible(true);
            //propPanel.setVisible(true);
        }
    });
    openRecentMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.recent"));
    JMenuItem exitMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.exit"));
    exitMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {

            /*
            int opt = JOptionPane.showConfirmDialog(PuckFrame.this,Messages.getInstance().getMessage("exit.sure.text"),Messages.getInstance().getMessage("exit.sure.title"),JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
                    
            if ( opt == JOptionPane.YES_OPTION )
             System.exit(0);
            */
            userExit();

        }
    });
    JMenu exportMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.export"));
    JMenuItem exportAppletMenuItem = new JMenuItem(
            UIMessages.getInstance().getMessage("menu.file.export.applet"));
    exportAppletMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            ExportAppletDialog dial = new ExportAppletDialog(PuckFrame.this);
            dial.setVisible(true);
        }
    });
    exportMenu.add(exportAppletMenuItem);

    fileMenu.add(newMenu);
    fileMenu.add(openMenuItem);
    fileMenu.add(openRecentMenu);
    updateRecentMenu();
    fileMenu.add(new JSeparator());
    saveMenuItem.setEnabled(false);
    fileMenu.add(saveMenuItem);
    fileMenu.add(saveAsMenuItem);
    fileMenu.add(exportMenu);
    fileMenu.add(new JSeparator());
    fileMenu.add(exitMenuItem);

    mainMenuBar.add(fileMenu);

    /**
     * Create an Edit menu to support cut/copy/paste.
     */

    JMenu editMenu = new JMenu(UIMessages.getInstance().getMessage("menu.edit"));
    editMenu.setMnemonic(KeyEvent.VK_E);

    JMenuItem findMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.find.entity"));
    findMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showFindEntityDialog();
        }
    });
    editMenu.add(findMenuItem);
    editMenu.add(new JSeparator());

    JMenuItem aMenuItem = new JMenuItem(new CutAction());
    aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.cut"));
    aMenuItem.setMnemonic(KeyEvent.VK_T);
    editMenu.add(aMenuItem);

    aMenuItem = new JMenuItem(new CopyAction());
    aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.copy"));
    aMenuItem.setMnemonic(KeyEvent.VK_C);
    editMenu.add(aMenuItem);

    aMenuItem = new JMenuItem(new PasteAction());
    aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.paste"));
    aMenuItem.setMnemonic(KeyEvent.VK_P);
    editMenu.add(aMenuItem);

    mainMenuBar.add(editMenu);

    JMenu optionsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options"));
    JMenu gridMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.grid"));
    optionsMenu.add(gridMenu);
    final JCheckBoxMenuItem showGridItem = new JCheckBoxMenuItem(
            UIMessages.getInstance().getMessage("menu.options.grid.show"));
    showGridItem.setSelected(
            Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue());
    gridMenu.add(showGridItem);
    showGridItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                graphPanel.setGrid(true);
                PuckConfiguration.getInstance().setProperty("showGrid", "true");
            } else if (e.getStateChange() == ItemEvent.DESELECTED) {
                graphPanel.setGrid(false);
                PuckConfiguration.getInstance().setProperty("showGrid", "false");
            }
            graphPanel.repaint();
        }
    });
    final JCheckBoxMenuItem snapToGridItem = new JCheckBoxMenuItem(
            UIMessages.getInstance().getMessage("menu.options.grid.snap"));
    snapToGridItem.setSelected(
            Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue());
    gridMenu.add(snapToGridItem);
    snapToGridItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                graphPanel.setSnapToGrid(true);
                PuckConfiguration.getInstance().setProperty("snapToGrid", "true");
            } else if (e.getStateChange() == ItemEvent.DESELECTED) {
                graphPanel.setSnapToGrid(false);
                PuckConfiguration.getInstance().setProperty("snapToGrid", "false");
            }
            graphPanel.repaint();
        }
    });

    JMenuItem translationModeMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.translation"));
    ButtonGroup translationGroup = new ButtonGroup();
    final JRadioButtonMenuItem holdMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.translation.hold"));
    final JRadioButtonMenuItem pushMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.translation.push"));
    pushMenuItem.setSelected("push".equals(PuckConfiguration.getInstance().getProperty("translateMode")));
    if (!pushMenuItem.isSelected())
        holdMenuItem.setSelected(true);
    translationGroup.add(holdMenuItem);
    translationGroup.add(pushMenuItem);
    holdMenuItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent arg0) {
            if (holdMenuItem.isSelected())
                PuckConfiguration.getInstance().setProperty("translateMode", "hold");
            else
                PuckConfiguration.getInstance().setProperty("translateMode", "push");
        }
    });
    translationModeMenu.add(holdMenuItem);
    translationModeMenu.add(pushMenuItem);
    optionsMenu.add(translationModeMenu);

    JMenuItem toolSelectionModeMenu = new JMenu(
            UIMessages.getInstance().getMessage("menu.options.toolselection"));
    ButtonGroup toolSelectionGroup = new ButtonGroup();
    final JRadioButtonMenuItem oneUseMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.toolselection.oneuse"));
    final JRadioButtonMenuItem multipleUseMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.toolselection.multipleuse"));
    multipleUseMenuItem.setSelected(
            "multipleUse".equalsIgnoreCase(PuckConfiguration.getInstance().getProperty("toolSelectionMode")));
    if (!multipleUseMenuItem.isSelected())
        oneUseMenuItem.setSelected(true);
    toolSelectionGroup.add(oneUseMenuItem);
    toolSelectionGroup.add(multipleUseMenuItem);
    oneUseMenuItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent arg0) {
            if (oneUseMenuItem.isSelected())
                PuckConfiguration.getInstance().setProperty("toolSelectionMode", "oneUse");
            else
                PuckConfiguration.getInstance().setProperty("toolSelectionMode", "multipleUse");
        }
    });
    toolSelectionModeMenu.add(oneUseMenuItem);
    toolSelectionModeMenu.add(multipleUseMenuItem);
    optionsMenu.add(toolSelectionModeMenu);

    JMenuItem sizesMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.iconsizes"));
    sizesMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            IconSizesDialog dial = new IconSizesDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    optionsMenu.add(sizesMenuItem);

    JMenuItem showHideMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.showhide"));
    showHideMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ShowHideDialog dial = new ShowHideDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    optionsMenu.add(showHideMenuItem);

    JMenuItem mapColorsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.mapcolors"));
    mapColorsMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            MapColorsDialog dial = new MapColorsDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    optionsMenu.add(mapColorsMenuItem);

    String skinList = PuckConfiguration.getInstance().getProperty("availableSkins");
    if (skinList != null && skinList.trim().length() > 0) {
        JMenu skinsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.skins"));
        StringTokenizer st = new StringTokenizer(skinList, ", ");
        ButtonGroup skinButtons = new ButtonGroup();
        while (st.hasMoreTokens()) {
            final String nextSkin = st.nextToken();
            final JRadioButtonMenuItem skinMenuItem = new JRadioButtonMenuItem(nextSkin);
            skinMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    setSkin(nextSkin);
                    skinMenuItem.setSelected(true);
                }
            });
            if (nextSkin.equals(PuckConfiguration.getInstance().getProperty("skin")))
                skinMenuItem.setSelected(true);
            skinsMenu.add(skinMenuItem);
            skinButtons.add(skinMenuItem);
        }
        optionsMenu.add(skinsMenu);
    }

    JMenu lookFeelMenu = new JMenu(UIMessages.getInstance().getMessage("menu.looks"));
    ButtonGroup lookButtons = new ButtonGroup();
    final JRadioButtonMenuItem defaultLookMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.looks.default"));
    if ("default".equals(PuckConfiguration.getInstance().getProperty("look"))) {
        defaultLookMenuItem.setSelected(true);
    }
    lookFeelMenu.add(defaultLookMenuItem);
    lookButtons.add(defaultLookMenuItem);
    defaultLookMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setLookAndFeel("default");
            defaultLookMenuItem.setSelected(true);
        }
    });
    final JRadioButtonMenuItem systemLookMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.looks.system"));
    if ("system".equals(PuckConfiguration.getInstance().getProperty("look"))) {
        systemLookMenuItem.setSelected(true);
    }
    lookFeelMenu.add(systemLookMenuItem);
    lookButtons.add(systemLookMenuItem);
    systemLookMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setLookAndFeel("system");
            systemLookMenuItem.setSelected(true);
        }
    });
    String additionalLookList = PuckConfiguration.getInstance().getProperty("additionalLooks");
    if (additionalLookList != null && additionalLookList.trim().length() > 0) {
        StringTokenizer st = new StringTokenizer(additionalLookList, ", ");
        while (st.hasMoreTokens()) {
            final String nextLook = st.nextToken();
            final JRadioButtonMenuItem lookMenuItem = new JRadioButtonMenuItem(nextLook);
            lookMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    setLookAndFeel(nextLook);
                    lookMenuItem.setSelected(true);
                }
            });
            if (nextLook.equals(PuckConfiguration.getInstance().getProperty("look"))) {
                lookMenuItem.setSelected(true);
            }
            lookFeelMenu.add(lookMenuItem);
            lookButtons.add(lookMenuItem);
        }
    }
    optionsMenu.add(lookFeelMenu);

    optionsMenu.add(new UILanguageSelectionMenu(this));

    mainMenuBar.add(optionsMenu);

    JMenu toolsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.tools"));

    final JMenuItem verbListMenuItem = new JMenuItem(
            UIMessages.getInstance().getMessage("menu.tools.verblist"));
    verbListMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            WorldPanel wp = (WorldPanel) graphPanel.getWorldNode().getAssociatedPanel();
            VerbListFrame vlf = VerbListFrame.getInstance(wp.getSelectedLanguageCode());
            vlf.setVisible(true);
        }
    });
    toolsMenu.add(verbListMenuItem);

    final JMenuItem validateMenuItem = new JMenuItem(
            UIMessages.getInstance().getMessage("menu.tools.validatebsh"));
    validateMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            BeanShellCodeValidator bscv = new BeanShellCodeValidator(graphPanel);
            if (!bscv.validate()) {
                BeanShellErrorsDialog bsed = new BeanShellErrorsDialog(PuckFrame.this, bscv.getErrorText());
                bsed.setVisible(true);
                //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText());
            } else {
                JOptionPane.showMessageDialog(PuckFrame.this,
                        UIMessages.getInstance().getMessage("bsh.code.ok"), "OK!",
                        JOptionPane.INFORMATION_MESSAGE);
                //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText());
            }
        }
    });
    toolsMenu.add(validateMenuItem);

    mainMenuBar.add(toolsMenu);

    JMenu helpMenu = new JMenu(UIMessages.getInstance().getMessage("menu.help"));
    //JHelpAction.startHelpWorker("help/PUCKHelp.hs");
    //JHelpAction helpTocAction = JHelpAction.getShowHelpInstance(Messages.getInstance().getMessage("menu.help.toc"));
    //JHelpAction helpContextSensitiveAction = JHelpAction.getTrackInstance(Messages.getInstance().getMessage("menu.help.context"));
    //final JMenuItem helpTocMenuItem = new JMenuItem(helpTocAction);
    //final JMenuItem helpContextSensitiveMenuItem = new JMenuItem(helpContextSensitiveAction);
    //helpMenu.add(helpTocMenuItem);
    //helpMenu.add(helpContextSensitiveMenuItem);

    final JMenuItem helpMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.help.toc"));
    helpMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DocumentationLinkDialog dial = new DocumentationLinkDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    helpMenu.add(helpMenuItem);

    mainMenuBar.add(helpMenu);

    MenuMnemonicOnTheFly.setMnemonics(mainMenuBar);

    this.setJMenuBar(mainMenuBar);

    //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            userExit();
        }
    });

    propPanel.show(graphPanel.getWorldNode());

    setVisible(true);

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            if (dividerLoc > 0)
                split.setDividerLocation(dividerLoc);
            else
                split.setDividerLocation(0.60);
        }
    });

}