Example usage for javax.swing JMenuItem addActionListener

List of usage examples for javax.swing JMenuItem addActionListener

Introduction

In this page you can find the example usage for javax.swing JMenuItem addActionListener.

Prototype

public void addActionListener(ActionListener l) 

Source Link

Document

Adds an ActionListener to the button.

Usage

From source file:corelyzer.ui.CorelyzerGLCanvas.java

void createPopupMenuUI() {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    this.scenePopupMenu = new JPopupMenu();

    JMenuItem trackName = new JMenuItem("Track Name");
    trackName.setEnabled(false);/*  ww  w . jav  a  2  s  . c om*/
    this.scenePopupMenu.add(trackName);

    JMenuItem sectionName = new JMenuItem("Section name");
    sectionName.setEnabled(false);
    this.scenePopupMenu.add(sectionName);

    this.scenePopupMenu.addSeparator();

    // Mode menu
    JMenu modeMenu = new JMenu("Mode");
    ButtonGroup modeGroup = new ButtonGroup();
    this.normalMode = new JRadioButtonMenuItem("Normal mode");
    this.normalMode.setIcon(new ImageIcon(getClass().getResource("/corelyzer/ui/resources/normal.gif")));
    this.normalMode.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            CorelyzerApp.getApp().getToolFrame().setMode(0);
        }
    });
    this.normalMode.setSelected(true);
    modeGroup.add(this.normalMode);
    modeMenu.add(this.normalMode);

    this.clastMode = new JRadioButtonMenuItem("Create annotation mode");
    this.clastMode.setIcon(new ImageIcon(getClass().getResource("/corelyzer/ui/resources/copyright.gif")));
    this.clastMode.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            CorelyzerApp.getApp().getToolFrame().setMode(3);
        }
    });
    modeGroup.add(this.clastMode);
    modeMenu.add(this.clastMode);

    this.markerMode = new JRadioButtonMenuItem("Modify annotation marker mode");
    this.markerMode.setIcon(new ImageIcon(getClass().getResource("/corelyzer/ui/resources/marker.gif")));
    this.markerMode.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            CorelyzerApp.getApp().getToolFrame().setMode(2);
        }
    });
    modeGroup.add(this.markerMode);
    modeMenu.add(this.markerMode);

    this.measureMode = new JRadioButtonMenuItem("Measure mode");
    this.measureMode.setIcon(new ImageIcon(getClass().getResource("/corelyzer/ui/resources/ruler.gif")));
    this.measureMode.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            CorelyzerApp.getApp().getToolFrame().setMode(1);
        }
    });
    modeGroup.add(this.measureMode);
    modeMenu.add(this.measureMode);

    this.cutMode = new JRadioButtonMenuItem("Cut mode");
    this.cutMode.setIcon(new ImageIcon(getClass().getResource("/corelyzer/ui/resources/cut.gif")));
    this.cutMode.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            CorelyzerApp.getApp().getToolFrame().setMode(4);
        }
    });
    modeGroup.add(this.cutMode);
    modeMenu.add(this.cutMode);

    this.scenePopupMenu.add(modeMenu);

    JMenuItem hideTrackMenuItem = new JMenuItem("Hide track");
    hideTrackMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            doHideTrack();
        }
    });
    this.scenePopupMenu.add(hideTrackMenuItem);

    JMenuItem exportTrackMenuItem = new JMenuItem("Export track");
    exportTrackMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent actionEvent) {
            doExportTrack();
        }
    });
    this.scenePopupMenu.add(exportTrackMenuItem);

    JMenuItem lockSectionMenuItem = new JCheckBoxMenuItem("Lock Section");
    lockSectionMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent actionEvent) {
            AbstractButton b = (AbstractButton) actionEvent.getSource();
            doLockSection(b.getModel().isSelected());
        }
    });

    JMenuItem lockSectionGraphMenuItem = new JCheckBoxMenuItem("Lock Section Graphs");
    lockSectionGraphMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent actionEvent) {
            AbstractButton b = (AbstractButton) actionEvent.getSource();
            doLockSectionGraph(b.getModel().isSelected());
        }
    });

    JMenuItem graphMenuItem = new JMenuItem("Graph...");
    graphMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            doGraphDialog();
        }
    });

    this.propertyMenuItem = new JMenuItem("Properties...");
    this.propertyMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            SectionImagePropertyDialog dialog = new SectionImagePropertyDialog(canvas);
            dialog.setProperties(selectedTrack, selectedTrackSection);
            dialog.pack();
            dialog.setLocationRelativeTo(canvas);
            dialog.setVisible(true);
            dialog.dispose();
        }
    });

    splitMenuItem = new JMenuItem("Split...");
    splitMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            CorelyzerApp app = CorelyzerApp.getApp();
            if (app != null) {
                app.getController().sectionSplit();
            }
        }
    });

    JMenuItem deleteItem = new JMenuItem("Delete...");
    deleteItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent actionEvent) {
            doDeleteSection();
        }
    });

    JMenuItem staggerSectionsItem = new JCheckBoxMenuItem("Stagger Sections", false);
    staggerSectionsItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            AbstractButton b = (AbstractButton) e.getSource();
            doStaggerSections(b.getModel().isSelected());
        }
    });

    JMenuItem trimSectionsItem = new JMenuItem("Trim Sections...");
    trimSectionsItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            doTrimSections();
        }
    });

    JMenuItem stackSectionsItem = new JMenuItem("Stack Sections");
    stackSectionsItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            doStackSections();
        }
    });

    this.scenePopupMenu.addSeparator();
    this.scenePopupMenu.add(lockSectionMenuItem);
    this.scenePopupMenu.add(lockSectionGraphMenuItem);
    this.scenePopupMenu.addSeparator();
    this.scenePopupMenu.add(graphMenuItem);
    this.scenePopupMenu.add(splitMenuItem);
    this.scenePopupMenu.add(propertyMenuItem);
    this.scenePopupMenu.add(deleteItem);
    this.scenePopupMenu.add(staggerSectionsItem);
    this.scenePopupMenu.add(trimSectionsItem);
    this.scenePopupMenu.add(stackSectionsItem);

    CorelyzerApp.getApp().getPluginManager().addPluginPopupSubMenus(this.scenePopupMenu);
}

From source file:mondrian.gui.Workbench.java

private void newQueryMenuItemActionPerformed(ActionEvent evt) {
    JMenuItem schemaMenuItem = schemaWindowMap.get(desktopPane.getSelectedFrame());

    final JInternalFrame jf = new JInternalFrame();
    jf.setTitle(getResourceConverter().getString("workbench.new.MDXQuery.title", "MDX Query"));
    QueryPanel qp = new QueryPanel(this);

    jf.getContentPane().add(qp);//  w ww  . jav a  2 s.  c  om
    jf.setBounds(0, 0, 500, 480);
    jf.setClosable(true);
    jf.setIconifiable(true);
    jf.setMaximizable(true);
    jf.setResizable(true);
    jf.setVisible(true);

    desktopPane.add(jf);
    jf.show();
    try {
        jf.setSelected(true);
    } catch (Exception ex) {
        // do nothing
        LOGGER.error("newQueryMenuItemActionPerformed.setSelected", ex);
    }

    // add the mdx frame to this set of mdx frames for cascading method
    mdxWindows.add(jf);

    // create mdx menu item
    final javax.swing.JMenuItem queryMenuItem = new javax.swing.JMenuItem();
    queryMenuItem.setText(getResourceConverter().getFormattedString("workbench.new.MDXQuery.menuitem",
            "{0} MDX", Integer.toString(windowMenuMapIndex)));
    queryMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                if (jf.isIcon()) {
                    jf.setIcon(false);
                } else {
                    jf.setSelected(true);
                }
            } catch (Exception ex) {
                LOGGER.error("queryMenuItem", ex);
            }
        }
    });

    // disable mdx frame close operation to provide our handler
    // to remove frame object from mdxframeset before closing
    jf.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    jf.addInternalFrameListener(new InternalFrameAdapter() {
        public void internalFrameClosing(InternalFrameEvent e) {
            mdxWindows.remove(jf);
            jf.dispose();
            // follow this by removing file from schemaWindowMap
            windowMenu.remove(queryMenuItem);
            return;
        }
    });

    windowMenu.add(queryMenuItem, -1);
    windowMenu.add(jSeparator3, -1);
    windowMenu.add(cascadeMenuItem, -1);
    windowMenu.add(tileMenuItem, -1);
    windowMenu.add(minimizeMenuItem, -1);
    windowMenu.add(maximizeMenuItem, -1);
    windowMenu.add(closeAllMenuItem, -1);

    qp.setMenuItem(queryMenuItem);
    qp.setSchemaWindowMap(schemaWindowMap);
    qp.setWindowMenuIndex(windowMenuMapIndex++);

    if (schemaMenuItem != null) {
        qp.initConnection(schemaMenuItem.getText());
    } else {
        JOptionPane.showMessageDialog(this,
                getResourceConverter().getString("workbench.new.MDXQuery.no.selection",
                        "No Mondrian connection. Select a Schema to connect."),
                getResourceConverter().getString("workbench.new.MDXQuery.no.selection.title", "Alert"),
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:mondrian.gui.Workbench.java

private void newJDBCExplorerMenuItemActionPerformed(ActionEvent evt) {
    try {//w w  w .j  a va 2s  . c  o  m
        if (jdbcMetaData == null) {
            getNewJdbcMetadata();
        }

        final JInternalFrame jf = new JInternalFrame();

        jf.setTitle(getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.title",
                "JDBC Explorer - {0} {1}", jdbcMetaData.getDatabaseProductName(),
                jdbcMetaData.getJdbcConnectionUrl()));
        getNewJdbcMetadata();

        JdbcExplorer jdbce = new JdbcExplorer(jdbcMetaData, this);

        jf.getContentPane().add(jdbce);
        jf.setBounds(0, 0, 500, 480);
        jf.setClosable(true);
        jf.setIconifiable(true);
        jf.setMaximizable(true);
        jf.setResizable(true);
        jf.setVisible(true);

        // create jdbc menu item
        final javax.swing.JMenuItem jdbcMenuItem = new javax.swing.JMenuItem();
        jdbcMenuItem.setText(getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.menuitem",
                "{0} JDBC Explorer", Integer.toString(windowMenuMapIndex++)));
        jdbcMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                try {
                    if (jf.isIcon()) {
                        jf.setIcon(false);
                    } else {
                        jf.setSelected(true);
                    }
                } catch (Exception ex) {
                    LOGGER.error("queryMenuItem", ex);
                }
            }
        });

        jf.addInternalFrameListener(new InternalFrameAdapter() {
            public void internalFrameClosing(InternalFrameEvent e) {
                jdbcWindows.remove(jf);
                jf.dispose();
                // follow this by removing file from schemaWindowMap
                windowMenu.remove(jdbcMenuItem);
                return;
            }
        });

        desktopPane.add(jf);
        jf.setVisible(true);
        jf.show();

        try {
            jf.setSelected(true);
        } catch (Exception ex) {
            // do nothing
            LOGGER.error("newJDBCExplorerMenuItemActionPerformed.setSelected", ex);
        }

        jdbcWindows.add(jf);

        windowMenu.add(jdbcMenuItem, -1);
        windowMenu.add(jSeparator3, -1);
        windowMenu.add(cascadeMenuItem, -1);
        windowMenu.add(tileMenuItem, -1);
        windowMenu.add(minimizeMenuItem, -1);
        windowMenu.add(maximizeMenuItem, -1);
        windowMenu.add(closeAllMenuItem, -1);
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(this,
                getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.exception",
                        "Database connection not successful.\n{0}", ex.getLocalizedMessage()),
                getResourceConverter().getString("workbench.new.JDBCExplorer.exception.title",
                        "Database Connection Error"),
                JOptionPane.ERROR_MESSAGE);
        LOGGER.error("newJDBCExplorerMenuItemActionPerformed", ex);
    }
}

From source file:gtu._work.mvn.MavenRepositoryUI.java

void defaultPopupMenu(final List<PomFile> pomFileList, Component component, MouseEvent evt) {
    if (pomFileList == null || pomFileList.isEmpty()) {
        return;//from   w  w w .  ja  v  a 2 s  . com
    }
    final PomFile pomFile = pomFileList.size() == 1 ? pomFileList.get(0) : null;

    if (pomFileList.size() > 0) {
        final JMenuItem copyAllMenu = new JMenuItem();
        {
            final Set<File> jarList = new HashSet<File>();
            final StringBuilder sb = new StringBuilder();
            for (PomFile _pomFile : pomFileList) {
                if (_pomFile.jarFile != null) {
                    sb.append(_pomFile.jarFile.getName() + "\n");
                    jarList.add(_pomFile.jarFile);
                }
            }
            if (sb.length() > 200) {
                sb.delete(200, sb.length() - 1);
                sb.append("...etc");
            }

            final String title = "COPY SELECTED JAR : " + jarList.size();
            copyAllMenu.setText(title);
            copyAllMenu.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent paramActionEvent) {
                    System.out.println("# copyMenu action ...");
                    JOptionPaneUtil.ComfirmDialogResult result = JOptionPaneUtil.newInstance()
                            .confirmButtonYesNoCancel().showConfirmDialog(//
                                    "are you sure copy file : \n" + sb + "\tto \n" + copyTo + "\n\t???", title);
                    if (result != JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION) {
                        return;
                    }

                    new Thread(Thread.currentThread().getThreadGroup(), new Runnable() {
                        public void run() {
                            long startTime = System.currentTimeMillis();
                            File copyToFile = null;
                            int successCount = 0;
                            int errorCount = 0;
                            StringBuilder err = new StringBuilder();
                            for (File jar : jarList) {
                                copyToFile = new File(copyTo, jar.getName());
                                try {
                                    FileUtil.copyFile(jar, copyToFile);
                                    successCount++;
                                } catch (IOException e) {
                                    e.printStackTrace();
                                    errorCount++;
                                    err.append(jar + "\n");
                                }
                            }
                            JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(//
                                    "copy completed!! \n" + //
                            "during : " + (System.currentTimeMillis() - startTime) + "\n" + "success : "
                                            + successCount + "\n" + //
                            "fail : " + errorCount + "\n" + //
                            "fail list : \n" + err, "COMPLETED");
                        }
                    }, "copy all jar to target " + hashCode()).start();
                }
            });
        }

        final JMenuItem copyAllNewMenu = new JMenuItem();
        {
            final Set<File> jarList = new HashSet<File>();
            final StringBuilder sb = new StringBuilder();
            DependencyKey depenKey = null;
            PomFile _newPomFile = null;
            for (PomFile _pomFile : pomFileList) {
                if (_pomFile.jarFile != null) {
                    depenKey = new DependencyKey(_pomFile.pom.groupId, _pomFile.pom.artifactId);
                    if (pomFileMap.containsKey(depenKey)) {
                        _newPomFile = pomFileMap.get(depenKey);
                        System.out.println("find new success: " + _pomFile + " --> " + _newPomFile);
                        _pomFile = _newPomFile;
                    } else {
                        System.out.println("find new faild!!: " + _pomFile);
                    }
                    if (_pomFile.jarFile != null) {
                        sb.append(_pomFile.jarFile.getName() + "\n");
                        jarList.add(_pomFile.jarFile);
                    }
                }
            }
            if (sb.length() > 200) {
                sb.delete(200, sb.length() - 1);
                sb.append("...etc");
            }

            final String title = "COPY SELECTED JAR(newest) : " + jarList.size();
            copyAllNewMenu.setText(title);
            copyAllNewMenu.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent paramActionEvent) {
                    System.out.println("# copyMenu action ...");
                    JOptionPaneUtil.ComfirmDialogResult result = JOptionPaneUtil.newInstance()
                            .confirmButtonYesNoCancel().showConfirmDialog(//
                                    "are you sure copy file : \n" + sb + "\tto \n" + copyTo + "\n\t???", title);
                    if (result != JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION) {
                        return;
                    }

                    new Thread(Thread.currentThread().getThreadGroup(), new Runnable() {
                        public void run() {
                            long startTime = System.currentTimeMillis();
                            File copyToFile = null;
                            int successCount = 0;
                            int errorCount = 0;
                            StringBuilder err = new StringBuilder();
                            for (File jar : jarList) {
                                copyToFile = new File(copyTo, jar.getName());
                                try {
                                    FileUtil.copyFile(jar, copyToFile);
                                    successCount++;
                                } catch (IOException e) {
                                    e.printStackTrace();
                                    errorCount++;
                                    err.append(jar + "\n");
                                }
                            }
                            JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(//
                                    "copy completed!! \n" + //
                            "during : " + (System.currentTimeMillis() - startTime) + "\n" + "success : "
                                            + successCount + "\n" + //
                            "fail : " + errorCount + "\n" + //
                            "fail list : \n" + err, "COMPLETED");
                        }
                    }, "copy all jar to target " + hashCode()).start();
                }
            });
        }

        JPopupMenuUtil.newInstance(component).applyEvent(evt).addJMenuItem(copyAllMenu, copyAllNewMenu).show();
    }

    if (pomFile != null) {
        final JMenuItem copyMenu = new JMenuItem();
        {
            if (pomFile.jarFile == null) {
                copyMenu.setText("COPY : no jar file");
                copyMenu.setEnabled(false);
            } else if (copyTo == null) {
                copyMenu.setText("COPY : copy to not set");
                copyMenu.setEnabled(false);
            } else {
                copyMenu.setText("COPY : " + this.getJarName(pomFile));
                copyMenu.setEnabled(true);
            }
            copyMenu.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent paramActionEvent) {
                    System.out.println("# copyMenu action ...");
                    File copyToFile = new File(copyTo, pomFile.jarFile.getName());
                    JOptionPaneUtil.ComfirmDialogResult result = JOptionPaneUtil.newInstance()
                            .confirmButtonYesNoCancel().showConfirmDialog(//
                                    "are you sure copy file : \n" + //
                    pomFile.jarFile.getParent() + "\nto\n" + //
                    copyToFile.getParent() + "\n" + //
                    "\t???", getJarName(pomFile));
                    if (result == JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION) {
                        try {
                            FileUtil.copyFile(pomFile.jarFile, copyToFile);
                        } catch (IOException e) {
                            e.printStackTrace();
                            JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(e.toString(),
                                    "ERROR");
                        }
                        JOptionPaneUtil.newInstance().iconInformationMessage()
                                .showMessageDialog("copy success!!", "SUCCESS");
                    }
                }
            });
        }

        final JMenuItem updateSnapshotMenu = new JMenuItem();
        {
            updateSnapshotMenu.setText("update snapshot");
            updateSnapshotMenu.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent paramActionEvent) {
                    new Thread(Thread.currentThread().getThreadGroup(), new Runnable() {
                        public void run() {
                            try {
                                String command = String.format("cmd /c mvn -U -f \"%s\"", pomFile.xmlFile);
                                System.out.println(command);
                                final ProcessWatcher watcher = ProcessWatcher
                                        .newInstance(Runtime.getRuntime().exec("cmd /c @echo TODO!!"));
                                //TODO
                                //FIXME
                                //XXX
                                JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog("TODO",
                                        "MAVEN UPDATE");
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                            }
                        }
                    }, "execute Maven update").start();
                }
            });
        }

        final JMenuItem jdJarMenu = new JMenuItem();
        {
            jdJarMenu.setText("jd-gui");
            if (pomFile.jarFile == null) {
                jdJarMenu.setEnabled(false);
            }
            jdJarMenu.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent paramActionEvent) {
                    try {
                        Runtime.getRuntime().exec(String.format("cmd /c call \"%s\" \"%s\"", //
                                "C:/apps/jd-gui-0.3.1.windows/jd-gui.exe", pomFile.jarFile));
                    } catch (IOException ex) {
                        JCommonUtil.handleException(ex);
                    }
                }
            });
        }
        final JMenuItem openJarDirMenu = new JMenuItem();
        {
            openJarDirMenu.setText("open dir");
            openJarDirMenu.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent paramActionEvent) {
                    try {
                        Desktop.getDesktop().open(pomFile.xmlFile.getParentFile());
                    } catch (IOException ex) {
                        JCommonUtil.handleException(ex);
                    }
                }
            });
        }
        final JMenuItem showDepedencyMessage = new JMenuItem();
        {
            showDepedencyMessage.setText("show dependency");
            showDepedencyMessage.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent paramActionEvent) {
                    clipboardPomJarConfig(pomFile, true);
                }
            });
        }

        JPopupMenuUtil.newInstance(component).applyEvent(evt)
                .addJMenuItem(copyMenu, updateSnapshotMenu, jdJarMenu, openJarDirMenu, showDepedencyMessage)
                .show();
    }
}

From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java

protected JPopupMenu createWindowPopupMenu(final Window window) {
    JPopupMenu popupMenu = new JPopupMenu();

    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);

    if (clientConfig.getManualScreenSettingsSaving()) {
        JMenuItem saveSettingsItem = new JMenuItem(messages.getMainMessage("actions.saveSettings"));
        saveSettingsItem.addActionListener(new ActionListener() {
            @Override/* w  w  w .  j  a v a  2s  .  c  om*/
            public void actionPerformed(ActionEvent e) {
                window.saveSettings();
            }
        });
        popupMenu.add(saveSettingsItem);

        JMenuItem restoreToDefaultsItem = new JMenuItem(messages.getMainMessage("actions.restoreToDefaults"));
        restoreToDefaultsItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                window.deleteSettings();
            }
        });
        popupMenu.add(restoreToDefaultsItem);
    }
    if (clientConfig.getLayoutAnalyzerEnabled()) {
        JMenuItem analyzeLayoutItem = new JMenuItem(messages.getMainMessage("actions.analyzeLayout"));
        analyzeLayoutItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                LayoutAnalyzer analyzer = new LayoutAnalyzer();
                List<LayoutTip> tipsList = analyzer.analyze(window);

                if (tipsList.isEmpty()) {
                    showNotification("No layout problems found", NotificationType.HUMANIZED);
                } else {
                    window.openWindow("layoutAnalyzer", OpenType.DIALOG, ParamsMap.of("tipsList", tipsList));
                }
            }
        });
        popupMenu.add(analyzeLayoutItem);
    }
    return popupMenu;
}

From source file:BeanContainer.java

  protected JMenuBar createMenuBar() {
  JMenuBar menuBar = new JMenuBar();
    /*from   ww w .ja  v a  2 s . co  m*/
  JMenu mFile = new JMenu("File");

  JMenuItem mItem = new JMenuItem("New...");
  ActionListener lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {  
      Thread newthread = new Thread() {
        public void run() {
          String result = (String)JOptionPane.showInputDialog(
            BeanContainer.this, 
            "Please enter class name to create a new bean", 
            "Input", JOptionPane.INFORMATION_MESSAGE, null, 
            null, m_className);
          repaint();
          if (result==null)
            return;
          try {
            m_className = result;
            Class cls = Class.forName(result);
            Object obj = cls.newInstance();
            if (obj instanceof Component) {
              m_activeBean = (Component)obj;
              m_activeBean.addFocusListener(
                BeanContainer.this);
              m_activeBean.requestFocus();
              getContentPane().add(m_activeBean);
            }
            validate();
          }
          catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(
              BeanContainer.this, "Error: "+ex.toString(),
              "Warning", JOptionPane.WARNING_MESSAGE);
          }
        }
      };
      newthread.start();
    }
  };
  mItem.addActionListener(lst);
  mFile.add(mItem);

  mItem = new JMenuItem("Load...");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {  
      Thread newthread = new Thread() {
        public void run() {
          m_chooser.setCurrentDirectory(m_currentDir);
          m_chooser.setDialogTitle(
            "Please select file with serialized bean");
          int result = m_chooser.showOpenDialog(
            BeanContainer.this);
          repaint();
          if (result != JFileChooser.APPROVE_OPTION)
            return;
          m_currentDir = m_chooser.getCurrentDirectory();
          File fChoosen = m_chooser.getSelectedFile();
          try {
            FileInputStream fStream = 
              new FileInputStream(fChoosen);
            ObjectInput  stream  =  
              new ObjectInputStream(fStream);
            Object obj = stream.readObject();
            if (obj instanceof Component) {
              m_activeBean = (Component)obj;
              m_activeBean.addFocusListener(
                BeanContainer.this);
              m_activeBean.requestFocus();
              getContentPane().add(m_activeBean);
            }
            stream.close();
            fStream.close();
            validate();
          }
          catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(
              BeanContainer.this, "Error: "+ex.toString(),
              "Warning", JOptionPane.WARNING_MESSAGE);
          }
          repaint();
        }
      };
      newthread.start();
    }
  };
  mItem.addActionListener(lst);
  mFile.add(mItem);

  mItem = new JMenuItem("Save...");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      Thread newthread = new Thread() {
        public void run() {
          if (m_activeBean == null)
            return;
          m_chooser.setDialogTitle(
            "Please choose file to serialize bean");
          m_chooser.setCurrentDirectory(m_currentDir);
          int result = m_chooser.showSaveDialog(
            BeanContainer.this);
          repaint();
          if (result != JFileChooser.APPROVE_OPTION)
            return;
          m_currentDir = m_chooser.getCurrentDirectory();
          File fChoosen = m_chooser.getSelectedFile();
          try {
            FileOutputStream fStream = 
              new FileOutputStream(fChoosen);
            ObjectOutput stream  =  
              new ObjectOutputStream(fStream);
            stream.writeObject(m_activeBean);
            stream.close();
            fStream.close();
          }
          catch (Exception ex) {
            ex.printStackTrace();
          JOptionPane.showMessageDialog(
            BeanContainer.this, "Error: "+ex.toString(),
            "Warning", JOptionPane.WARNING_MESSAGE);
          }
        }
      };
      newthread.start();
    }
  };
  mItem.addActionListener(lst);
  mFile.add(mItem);

  mFile.addSeparator();

  mItem = new JMenuItem("Exit");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      System.exit(0);
    }
  };
  mItem.addActionListener(lst);
  mFile.add(mItem);
  menuBar.add(mFile);
    
  JMenu mEdit = new JMenu("Edit");

  mItem = new JMenuItem("Delete");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      if (m_activeBean == null)
        return;
      Object obj = m_editors.get(m_activeBean);
      if (obj != null) {
        BeanEditor editor = (BeanEditor)obj;
        editor.dispose();
        m_editors.remove(m_activeBean);
      }
      getContentPane().remove(m_activeBean);
      m_activeBean = null;
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  mEdit.add(mItem);

  mItem = new JMenuItem("Properties...");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      if (m_activeBean == null)
        return;
      Object obj = m_editors.get(m_activeBean);
      if (obj != null) {
        BeanEditor editor = (BeanEditor)obj;
        editor.setVisible(true);
        editor.toFront();
      }
      else {
        BeanEditor editor = new BeanEditor(m_activeBean);
        m_editors.put(m_activeBean, editor);
      }
    }
  };
  mItem.addActionListener(lst);
  mEdit.add(mItem);
  menuBar.add(mEdit);

  JMenu mLayout = new JMenu("Layout");
  ButtonGroup group = new ButtonGroup();

  mItem = new JRadioButtonMenuItem("FlowLayout");
  mItem.setSelected(true);
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e){
      getContentPane().setLayout(new FlowLayout());
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  group.add(mItem);
  mLayout.add(mItem);

  mItem = new JRadioButtonMenuItem("GridLayout");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e){
      int col = 3;
      int row = (int)Math.ceil(getContentPane().
        getComponentCount()/(double)col);
      getContentPane().setLayout(new GridLayout(row, col, 10, 10));
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  group.add(mItem);
  mLayout.add(mItem);
    
  mItem = new JRadioButtonMenuItem("BoxLayout - X");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      getContentPane().setLayout(new BoxLayout(
        getContentPane(), BoxLayout.X_AXIS));
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  group.add(mItem);
  mLayout.add(mItem);
    
  mItem = new JRadioButtonMenuItem("BoxLayout - Y");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      getContentPane().setLayout(new BoxLayout(
        getContentPane(), BoxLayout.Y_AXIS));
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  group.add(mItem);
  mLayout.add(mItem);
    
  mItem = new JRadioButtonMenuItem("DialogLayout");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      getContentPane().setLayout(new DialogLayout());
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  group.add(mItem);
  mLayout.add(mItem);

  menuBar.add(mLayout);

  return menuBar;
}

From source file:org.gumtree.vis.awt.JChartPanel.java

protected void addMaskMenu(int x, int y) {
    if (this.removeSelectedMaskMenuItem != null) {
        boolean isRemoveMenuEnabled = false;
        if (this.selectedMask != null) {
            Rectangle2D screenMask = ChartMaskingUtilities.getMaskFramework(selectedMask, getScreenDataArea(),
                    getChart());/*from   w ww.  ja  v a 2  s. co  m*/
            if (screenMask.contains(x, y)) {
                isRemoveMenuEnabled = true;
            }
        }
        this.removeSelectedMaskMenuItem.setEnabled(isRemoveMenuEnabled);
        if (isRemoveMenuEnabled) {
            removeSelectedMaskMenuItem.setVisible(true);
            removeSelectedMaskMenuItem.setText("Remove " + selectedMask.getName());
        } else {
            //              removeSelectedMaskMenuItem.setText("Mask Management");
            removeSelectedMaskMenuItem.setVisible(false);
        }
    }
    maskManagementMenu.removeAll();
    if (maskList.size() > 0) {
        maskManagementMenu.setEnabled(true);
        JMenuItem selectNoneMaskItem = new JRadioButtonMenuItem();
        selectNoneMaskItem.setText("Select None");
        selectNoneMaskItem.setActionCommand(DESELECT_MASK_COMMAND);
        selectNoneMaskItem.addActionListener(this);
        maskManagementMenu.add(selectNoneMaskItem);
        boolean isInShade = false;
        for (AbstractMask mask : maskList.keySet()) {
            Rectangle2D screenMask = ChartMaskingUtilities.getMaskFramework(mask, getScreenDataArea(),
                    getChart());
            if (screenMask.contains(x, y)) {
                JMenuItem selectMaskItem = new JRadioButtonMenuItem();
                selectMaskItem.setText("Select " + mask.getName());
                selectMaskItem.setActionCommand(SELECT_MASK_COMMAND + "-" + mask.getName());
                if (mask == selectedMask) {
                    selectMaskItem.setSelected(true);
                }
                selectMaskItem.addActionListener(this);
                maskManagementMenu.add(selectMaskItem);
                isInShade = true;
            }
        }
        if (isInShade) {
            if (selectedMask == null) {
                selectNoneMaskItem.setSelected(true);
            }
        } else {
            for (AbstractMask mask : getMasks()) {
                JMenuItem selectMaskItem = new JRadioButtonMenuItem();
                selectMaskItem.setText("Select " + mask.getName());
                selectMaskItem.setActionCommand(SELECT_MASK_COMMAND + "-" + mask.getName());
                if (mask == selectedMask) {
                    selectMaskItem.setSelected(true);
                }
                selectMaskItem.addActionListener(this);
                maskManagementMenu.add(selectMaskItem);
            }
            selectNoneMaskItem.setSelected(selectedMask == null);
        }
    } else {
        maskManagementMenu.setEnabled(false);
    }
}

From source file:net.cantab.hayward.george.OCS.Statics.java

/**
 * Display the command menu//  w  ww.  java2 s . c om
 */
public void launchCommandMenu() {
    if (curCommander == null) {
        return;
    }
    int i;
    JMenu theMenu = new JMenu();
    JMenuItem mi;
    for (i = 0; i < 2; i++) {
        int j;
        int k = 0;
        for (j = 0; j < theCommanders.length; j++) {
            if (theCommanders[j].sidesCommanded[i]) {
                k++;
            }
        }
        if (k != 0) {
            JMenu com = new JMenu("Commanders of the " + theSides[i].name + " side");
            for (j = 0; j < theCommanders.length; j++) {
                if (theCommanders[j].sidesCommanded[i]) {
                    mi = new JMenuItem(theCommanders[j].name);
                    mi.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                        }
                    });
                    mi.setEnabled(true);
                    com.add(mi);
                }
            }
            theMenu.add(com);
        }
        if (curCommander.sidesCommanded[i]) {
            final int m = i;
            mi = new JMenuItem("Resign from " + theSides[i].name + " side");
            mi.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    resignSide(m);
                }
            });
            mi.setEnabled(true);
            theMenu.add(mi);
            int n = 0;
            for (j = 0; j < theCommanders.length; j++) {
                if (theCommanders[j].sidesRequested[i]) {
                    n++;
                }
            }
            if (n != 0) {
                JMenu app = new JMenu("Approve to join " + theSides[i].name + " side");
                JMenu rej = new JMenu("Reject to join " + theSides[i].name + " side");
                for (j = 0; j < theCommanders.length; j++) {
                    if (theCommanders[j].sidesRequested[i]) {
                        mi = new JMenuItem(theCommanders[j].name);
                        final int p = j;
                        mi.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                acceptSide(m, p);
                            }
                        });
                        mi.setEnabled(true);
                        app.add(mi);
                        mi = new JMenuItem(theCommanders[j].name);
                        mi.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                rejectSide(m, p);
                            }
                        });
                        mi.setEnabled(true);
                        rej.add(mi);
                    }
                }
                theMenu.add(app);
                theMenu.add(rej);
            }
        } else {
            final int m = i;
            if (k != 0) {
                mi = new JMenuItem("Join " + theSides[i].name + " side");
                mi.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        joinSide(m);
                    }
                });
                mi.setEnabled(true);
                theMenu.add(mi);
            } else {
                mi = new JMenuItem("Command " + theSides[i].name + " side");
                mi.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        commandSide(m);
                    }
                });
                mi.setEnabled(true);
                theMenu.add(mi);
            }
        }
    }
    for (i = 0; i < 2; i++) {
        final int m = i;
        mi = new JMenuItem((showPZs[i] ? "Hide " : "Show ") + theSides[i].name + " PZs");
        mi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                displayPZs(m);
            }
        });
        mi.setEnabled(true);
        theMenu.add(mi);
        mi = new JMenuItem((showZOCs[i] ? "Hide " : "Show ") + theSides[i].name + " ZOCs");
        mi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                displayZOCs(m);
            }
        });
        mi.setEnabled(true);
        theMenu.add(mi);
        if (curCommander.sidesCommanded[i]) {
            mi = new JMenuItem((showHQs[i] ? "Hide " : "Show ") + theSides[i].name + " HQs");
            mi.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    displayHQs(m);
                }
            });
            mi.setEnabled(true);
            theMenu.add(mi);
        }
    }
    theMenu.getPopupMenu().show(commandLaunch, 0, commandLaunch.getHeight());
}

From source file:br.com.jinsync.view.FrmJInSync.java

/**
 * Initialize the contents of the frame.
 *///from w  w w .  j a  v  a2 s.co m
private void initialize() {

    Language.loadParameters();

    setBounds(100, 100, 1136, 665);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 0, 0 };
    gridBagLayout.rowHeights = new int[] { 600, 53, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 1.0, 0.0, 0.0, Double.MIN_VALUE };
    getContentPane().setLayout(gridBagLayout);

    grpFontes = new JTabbedPane(SwingConstants.TOP);
    GridBagConstraints gbc_grpFontes = new GridBagConstraints();
    gbc_grpFontes.insets = new Insets(0, 0, 5, 0);
    gbc_grpFontes.fill = GridBagConstraints.BOTH;
    gbc_grpFontes.gridx = 0;
    gbc_grpFontes.gridy = 0;
    getContentPane().add(grpFontes, gbc_grpFontes);

    tabCopybook = new JPanel();
    tabCopybook.setBackground(Color.WHITE);
    grpFontes.addTab(Language.tabCopy, null, tabCopybook, null);

    GridBagLayout gbl_tabCopybook = new GridBagLayout();
    gbl_tabCopybook.columnWidths = new int[] { 10, 1, 0, 349, 0, 0, 62, 28, 71, 0, 0, 0 };
    gbl_tabCopybook.rowHeights = new int[] { 1, 0, 0, 0 };
    gbl_tabCopybook.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    gbl_tabCopybook.rowWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE };
    tabCopybook.setLayout(gbl_tabCopybook);

    JLabel lblCopybook = new JLabel(Language.txtFilePds);
    GridBagConstraints gbc_lblCopybook = new GridBagConstraints();
    gbc_lblCopybook.anchor = GridBagConstraints.EAST;
    gbc_lblCopybook.insets = new Insets(0, 0, 5, 5);
    gbc_lblCopybook.gridx = 1;
    gbc_lblCopybook.gridy = 1;
    tabCopybook.add(lblCopybook, gbc_lblCopybook);

    txtPath = new JTextField();
    GridBagConstraints gbc_txtPath = new GridBagConstraints();
    gbc_txtPath.gridwidth = 4;
    gbc_txtPath.insets = new Insets(0, 0, 5, 5);
    gbc_txtPath.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtPath.gridx = 2;
    gbc_txtPath.gridy = 1;
    tabCopybook.add(txtPath, gbc_txtPath);
    txtPath.setColumns(10);

    JButton btnDiretorio = new JButton("");
    btnDiretorio.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/folder.png")));
    btnDiretorio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            openDirectory();
        }
    });
    GridBagConstraints gbc_btnDiretorio = new GridBagConstraints();
    gbc_btnDiretorio.insets = new Insets(0, 0, 5, 5);
    gbc_btnDiretorio.gridx = 6;
    gbc_btnDiretorio.gridy = 1;
    tabCopybook.add(btnDiretorio, gbc_btnDiretorio);

    btnClearCopy = new JButton("");
    btnClearCopy.setEnabled(false);
    btnClearCopy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            tableCopy = new JTable();
            scrCopy.setViewportView(tableCopy);
            tableString = new JTable();
            scrTableString.setViewportView(tableString);

            btnExcelString.setEnabled(false);
            btnClearString.setEnabled(false);
            textAreaString.setText("");

            console.removeAllElements();
            btnExcel.setEnabled(false);
            btnClearCopy.setEnabled(false);
            grpFontes.setEnabledAt(1, false);

            tableFile = new JTable();
            scrFile.setViewportView(tableFile);
            btnExcelFile.setEnabled(false);
            btnClearFile.setEnabled(false);
            grpFontes.setEnabledAt(2, false);

        }
    });
    btnClearCopy.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png")));
    GridBagConstraints gbc_btnLimpar = new GridBagConstraints();
    gbc_btnLimpar.fill = GridBagConstraints.BOTH;
    gbc_btnLimpar.insets = new Insets(0, 0, 5, 5);
    gbc_btnLimpar.gridx = 9;
    gbc_btnLimpar.gridy = 1;
    tabCopybook.add(btnClearCopy, gbc_btnLimpar);

    JButton btnProcessarBook = new JButton("");
    btnProcessarBook.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            loadData();
            btnClearCopy.setEnabled(true);
            grpFontes.setEnabledAt(1, true);
            grpFontes.setEnabledAt(2, true);
        }
    });
    btnProcessarBook.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png")));
    GridBagConstraints gbc_btnProcessarBook = new GridBagConstraints();
    gbc_btnProcessarBook.fill = GridBagConstraints.VERTICAL;
    gbc_btnProcessarBook.insets = new Insets(0, 0, 5, 5);
    gbc_btnProcessarBook.gridx = 7;
    gbc_btnProcessarBook.gridy = 1;
    tabCopybook.add(btnProcessarBook, gbc_btnProcessarBook);

    btnExcel = new JButton("");
    btnExcel.setEnabled(false);
    btnExcel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            expExcelBook();
            // exportarExcelBook(tableCopy, txtPath.getText(),
            // "Horizontal");
        }
    });
    btnExcel.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png")));
    GridBagConstraints gbc_btnExcel = new GridBagConstraints();
    gbc_btnExcel.insets = new Insets(0, 0, 5, 5);
    gbc_btnExcel.gridx = 8;
    gbc_btnExcel.gridy = 1;
    tabCopybook.add(btnExcel, gbc_btnExcel);

    // JScrollPane scrCopy = new JScrollPane();
    gbc_scrCopy = new GridBagConstraints();
    gbc_scrCopy.gridwidth = 9;
    gbc_scrCopy.insets = new Insets(0, 0, 0, 5);
    gbc_scrCopy.fill = GridBagConstraints.BOTH;
    gbc_scrCopy.gridx = 1;
    gbc_scrCopy.gridy = 2;
    // tabCopybook.add(scrCopy, gbc_scrCopy);

    panelConsole = new Panel();
    GridBagConstraints gbc_panelConsole = new GridBagConstraints();
    gbc_panelConsole.insets = new Insets(0, 0, 5, 0);
    gbc_panelConsole.fill = GridBagConstraints.BOTH;
    gbc_panelConsole.gridx = 0;
    gbc_panelConsole.gridy = 1;
    getContentPane().add(panelConsole, gbc_panelConsole);
    panelConsole.setLayout(new BorderLayout(0, 0));

    listTerminal = new JList<String>();
    listTerminal.setFont(new Font("Courier New", Font.PLAIN, 11));
    listTerminal.setModel(console);

    scrConsole = new JScrollPane(listTerminal);
    panelConsole.add(scrConsole);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnNewMenu = new JMenu(Language.menuParam);
    menuBar.add(mnNewMenu);

    JMenuItem mnItemUsuario = new JMenuItem(Language.menuParamUser);
    mnItemUsuario.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FrmUser frmUsuar = new FrmUser();
            frmUsuar.setLocationRelativeTo(null);
            frmUsuar.setVisible(true);
            setUser();
        }
    });
    mnNewMenu.add(mnItemUsuario);

    JMenuItem mnItemFtp = new JMenuItem(Language.menuParamFtp);
    mnItemFtp.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FrmFtp frmFtp = new FrmFtp();
            frmFtp.setLocationRelativeTo(null);
            frmFtp.setVisible(true);
            setFtp();
        }
    });

    mnNewMenu.add(mnItemFtp);

    JMenu mnAjuda = new JMenu(Language.menuHelp);
    menuBar.add(mnAjuda);

    JMenuItem mntmNewMenuItem = new JMenuItem(Language.menuHelpAbout);
    mntmNewMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            FrmAbout frmSobre = new FrmAbout();
            frmSobre.setLocationRelativeTo(null);
            frmSobre.setVisible(true);
        }
    });
    mnAjuda.add(mntmNewMenuItem);

    tabCopybook.setFont(new Font("Arial", Font.PLAIN, 12));
    tabCopybook.add(scrCopy, gbc_scrCopy);

    tabString = new JPanel();
    tabString.setFont(new Font("Arial", Font.PLAIN, 12));
    tabString.setBackground(Color.WHITE);
    grpFontes.addTab(Language.tabString, null, tabString, null);
    grpFontes.setEnabledAt(1, false);
    GridBagLayout gbl_tabString = new GridBagLayout();
    gbl_tabString.columnWidths = new int[] { 10, 1, 346, 349, 0, 0, 62, 28, 71, 0, 0, 0 };
    gbl_tabString.rowHeights = new int[] { 1, 0, 0, 17, 22, 0, 259, 0 };
    gbl_tabString.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    gbl_tabString.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
    tabString.setLayout(gbl_tabString);

    JLabel lblString = new JLabel("String:");
    GridBagConstraints gbc_lblString = new GridBagConstraints();
    gbc_lblString.anchor = GridBagConstraints.WEST;
    gbc_lblString.insets = new Insets(0, 0, 5, 5);
    gbc_lblString.gridx = 1;
    gbc_lblString.gridy = 1;
    tabString.add(lblString, gbc_lblString);

    textAreaString = new JTextArea();

    JScrollPane scrStringData = new JScrollPane(textAreaString);
    GridBagConstraints gbc_scrString = new GridBagConstraints();
    gbc_scrString.gridheight = 3;
    gbc_scrString.gridwidth = 8;
    gbc_scrString.insets = new Insets(0, 0, 5, 5);
    gbc_scrString.fill = GridBagConstraints.BOTH;
    gbc_scrString.gridx = 1;
    gbc_scrString.gridy = 2;
    tabString.add(scrStringData, gbc_scrString);

    btnClearString = new JButton("");
    btnClearString.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            scrTableString.setViewportView(tableString);
            btnExcelString.setEnabled(false);
            btnClearString.setEnabled(false);
            textAreaString.setText("");
            tableString = new JTable();
            scrTableString.setViewportView(tableString);
        }
    });

    btnExcelString = new JButton("");
    btnExcelString.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            expExcelString();
        }
    });

    JButton btnProcessarArq = new JButton("");
    btnProcessarArq.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            processString();
        }
    });
    btnProcessarArq.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png")));
    GridBagConstraints gbc_btnProcessarArq = new GridBagConstraints();
    gbc_btnProcessarArq.fill = GridBagConstraints.VERTICAL;
    gbc_btnProcessarArq.insets = new Insets(0, 0, 5, 5);
    gbc_btnProcessarArq.gridx = 9;
    gbc_btnProcessarArq.gridy = 2;
    tabString.add(btnProcessarArq, gbc_btnProcessarArq);
    btnExcelString.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png")));
    btnExcelString.setEnabled(false);
    GridBagConstraints gbc_btnExcelString = new GridBagConstraints();
    gbc_btnExcelString.fill = GridBagConstraints.VERTICAL;
    gbc_btnExcelString.insets = new Insets(0, 0, 5, 5);
    gbc_btnExcelString.gridx = 9;
    gbc_btnExcelString.gridy = 3;
    tabString.add(btnExcelString, gbc_btnExcelString);
    btnClearString.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png")));
    btnClearString.setEnabled(false);
    GridBagConstraints gbc_btnClearString = new GridBagConstraints();
    gbc_btnClearString.fill = GridBagConstraints.VERTICAL;
    gbc_btnClearString.insets = new Insets(0, 0, 5, 5);
    gbc_btnClearString.gridx = 9;
    gbc_btnClearString.gridy = 4;
    tabString.add(btnClearString, gbc_btnClearString);

    JLabel lblSaida = new JLabel(Language.txtOutput);
    GridBagConstraints gbc_lblSaida = new GridBagConstraints();
    gbc_lblSaida.insets = new Insets(0, 0, 5, 5);
    gbc_lblSaida.gridx = 1;
    gbc_lblSaida.gridy = 5;
    tabString.add(lblSaida, gbc_lblSaida);

    GridBagConstraints gbc_scrArquivo = new GridBagConstraints();
    gbc_scrArquivo.fill = GridBagConstraints.BOTH;
    gbc_scrArquivo.gridwidth = 9;
    gbc_scrArquivo.insets = new Insets(0, 0, 0, 5);
    gbc_scrArquivo.gridx = 1;
    gbc_scrArquivo.gridy = 6;
    tabString.add(scrTableString, gbc_scrArquivo);

    tabFile = new JPanel();
    tabFile.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
            // TODO Auto-generated method stub
            if (isProcessStarted) {
                int key = e.getKeyCode();
                if (key == KeyEvent.VK_ESCAPE) {
                    int opc = JOptionPane.showConfirmDialog(null, Language.msgCancelProcess, Language.msgInf,
                            JOptionPane.OK_CANCEL_OPTION);
                    if (opc == JOptionPane.OK_OPTION) {
                        escProcessFile();
                    }
                }
            }

        }

        @Override
        public void keyReleased(KeyEvent arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void keyTyped(KeyEvent arg0) {
            // TODO Auto-generated method stub

        }

    });

    tabFile.setFont(new Font("Arial", Font.PLAIN, 12));
    tabFile.setBackground(Color.WHITE);
    grpFontes.addTab(Language.tabFile, null, tabFile, null);
    grpFontes.setEnabledAt(2, false);
    GridBagLayout gbl_tabFile = new GridBagLayout();
    gbl_tabFile.columnWidths = new int[] { 10, 1, 49, 459, 0, 0, 62, 28, 0, 71, 0, 0, 0, 0 };
    gbl_tabFile.rowHeights = new int[] { 1, 0, 0, 17, 22, 0, 259, 0, 0 };
    gbl_tabFile.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    gbl_tabFile.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
    tabFile.setLayout(gbl_tabFile);

    JLabel lblFile = new JLabel(Language.txtFilePds);
    GridBagConstraints gbc_lblFile = new GridBagConstraints();
    gbc_lblFile.anchor = GridBagConstraints.EAST;
    gbc_lblFile.insets = new Insets(0, 0, 5, 5);
    gbc_lblFile.gridx = 1;
    gbc_lblFile.gridy = 1;
    tabFile.add(lblFile, gbc_lblFile);

    txtFile = new JTextField();
    txtFile.setColumns(10);
    GridBagConstraints gbc_txtFile = new GridBagConstraints();
    gbc_txtFile.gridwidth = 5;
    gbc_txtFile.insets = new Insets(0, 0, 5, 5);
    gbc_txtFile.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtFile.gridx = 2;
    gbc_txtFile.gridy = 1;
    tabFile.add(txtFile, gbc_txtFile);

    btnClearFile = new JButton("");
    btnClearFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {

            tableFile = new JTable();
            scrFile.setViewportView(tableFile);
            btnExcelFile.setEnabled(false);
            btnClearFile.setEnabled(false);
            progressBar.setStringPainted(true);
            progressBar.setValue(0);
            progressBar.setString("");

        }
    });

    btnExcelFile = new JButton("");
    btnExcelFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            expExcelFile();
        }
    });

    btnProcFile = new JButton("");
    btnProcFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            loadFile();
        }
    });

    btnDirFile = new JButton("");
    btnDirFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            openDirFile();
        }
    });
    btnDirFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/folder.png")));
    GridBagConstraints gbc_btnDirFile = new GridBagConstraints();
    gbc_btnDirFile.fill = GridBagConstraints.VERTICAL;
    gbc_btnDirFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnDirFile.gridx = 7;
    gbc_btnDirFile.gridy = 1;
    tabFile.add(btnDirFile, gbc_btnDirFile);
    btnProcFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png")));
    GridBagConstraints gbc_btnProcFile = new GridBagConstraints();
    gbc_btnProcFile.fill = GridBagConstraints.VERTICAL;
    gbc_btnProcFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnProcFile.gridx = 8;
    gbc_btnProcFile.gridy = 1;
    tabFile.add(btnProcFile, gbc_btnProcFile);
    btnExcelFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png")));
    btnExcelFile.setEnabled(false);
    GridBagConstraints gbc_btnExcelFile = new GridBagConstraints();
    gbc_btnExcelFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnExcelFile.gridx = 9;
    gbc_btnExcelFile.gridy = 1;
    tabFile.add(btnExcelFile, gbc_btnExcelFile);
    btnClearFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png")));
    btnClearFile.setEnabled(false);
    GridBagConstraints gbc_btnLimparFile = new GridBagConstraints();
    gbc_btnLimparFile.fill = GridBagConstraints.VERTICAL;
    gbc_btnLimparFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnLimparFile.gridx = 10;
    gbc_btnLimparFile.gridy = 1;
    tabFile.add(btnClearFile, gbc_btnLimparFile);

    JLabel lblTamanho = new JLabel(Language.txtFileLength);
    GridBagConstraints gbc_lblTamanho = new GridBagConstraints();
    gbc_lblTamanho.anchor = GridBagConstraints.WEST;
    gbc_lblTamanho.insets = new Insets(0, 0, 5, 5);
    gbc_lblTamanho.gridx = 1;
    gbc_lblTamanho.gridy = 2;
    tabFile.add(lblTamanho, gbc_lblTamanho);

    txtLength = new JTextField();
    GridBagConstraints gbc_txtTamanho = new GridBagConstraints();
    gbc_txtTamanho.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtTamanho.insets = new Insets(0, 0, 5, 5);
    gbc_txtTamanho.gridx = 2;
    gbc_txtTamanho.gridy = 2;
    tabFile.add(txtLength, gbc_txtTamanho);
    txtLength.setColumns(10);

    JLabel label_1 = new JLabel(Language.txtOutput);
    GridBagConstraints gbc_label_1 = new GridBagConstraints();
    gbc_label_1.anchor = GridBagConstraints.WEST;
    gbc_label_1.insets = new Insets(0, 0, 5, 5);
    gbc_label_1.gridx = 1;
    gbc_label_1.gridy = 3;
    tabFile.add(label_1, gbc_label_1);

    GridBagConstraints gbc_scrFile = new GridBagConstraints();
    gbc_scrFile.gridheight = 3;
    gbc_scrFile.fill = GridBagConstraints.BOTH;
    gbc_scrFile.gridwidth = 10;
    gbc_scrFile.insets = new Insets(0, 0, 5, 5);
    gbc_scrFile.gridx = 1;
    gbc_scrFile.gridy = 4;
    tabFile.add(scrFile, gbc_scrFile);

    progressBar = new JProgressBar();
    GridBagConstraints gbc_progressBar = new GridBagConstraints();
    gbc_progressBar.fill = GridBagConstraints.HORIZONTAL;
    gbc_progressBar.gridwidth = 10;
    gbc_progressBar.insets = new Insets(0, 0, 0, 5);
    gbc_progressBar.gridx = 1;
    gbc_progressBar.gridy = 7;
    tabFile.add(progressBar, gbc_progressBar);

    JLabel lblNewLabel = new JLabel(Language.txtDeveloped + " Rodrigo Augusto Silva dos Santos - 2016");
    GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
    gbc_lblNewLabel.gridx = 0;
    gbc_lblNewLabel.gridy = 2;
    getContentPane().add(lblNewLabel, gbc_lblNewLabel);

    loadParameters();

}

From source file:edu.ku.brc.specify.tasks.QueryTask.java

@Override
public JPopupMenu getPopupMenu() {
    JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem mi = new JMenuItem(UIRegistry.getResourceString("QY_CONFIGURE_CREATORS"));
    popupMenu.add(mi);//from  www.j  a  v  a 2s.c o  m

    mi.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            configureCreatorQueries();
        }
    });

    mi = new JMenuItem(UIRegistry.getResourceString("QY_CONFIGURE_QUERIES"));
    popupMenu.add(mi);

    mi.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            configureFavoriteQueries();
        }
    });

    mi = new JMenuItem(UIRegistry.getResourceString("QY_IMPORT_QUERIES"));
    popupMenu.add(mi);

    mi.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            importQueries();
        }
    });

    mi = new JMenuItem(UIRegistry.getResourceString("QY_EXPORT_QUERIES"));
    popupMenu.add(mi);

    mi.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            exportQueries();
        }
    });

    return popupMenu;
}