Example usage for javax.swing JMenu JMenu

List of usage examples for javax.swing JMenu JMenu

Introduction

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

Prototype

public JMenu() 

Source Link

Document

Constructs a new JMenu with no text.

Usage

From source file:com.sec.ose.osi.ui.frm.main.JMenuMain.java

/**
 * This method initializes jMenuFile   /*from w w w  . j  a  v  a2  s .c o m*/
 *    
 * @return javax.swing.JMenu   
 */
private JMenu getJMenuFile() {
    if (jMenuFile == null) {
        jMenuFile = new JMenu();
        jMenuFile.setText("File");
        jMenuFile.add(getJMenuItemAnalysis());
        jMenuFile.add(getJMenuItemIdentify());
        jMenuFile.add(getJMenuItemReport());
        jMenuFile.addSeparator();
        jMenuFile.add(getJMenuItemExit());

    }
    return jMenuFile;
}

From source file:ec.nbdemetra.chainlinking.outlineview.ChainLinkingChart.java

private JMenu createPopupMenu() {
    JMenu rslt = new JMenu();
    rslt.add(newExportMenu());

    return rslt;
}

From source file:com.sec.ose.osi.ui.frm.main.JMenuMain.java

/**
 * This method initializes jMenuTool   /*from   w w w  . ja v a  2  s  . c  o  m*/
 *    
 * @return javax.swing.JMenu   
 */
private JMenu getJMenuTool() {
    if (jMenuTool == null) {
        jMenuTool = new JMenu();
        jMenuTool.setText("Tool");

        jMenuTool.add(getJMenuItemSyncFromServer());
        jMenuTool.add(getJMenuItemSyncToServer());
        jMenuTool.add(getJMenuItemSPDXAutoIdentify());

        jMenuTool.addSeparator();
        jMenuTool.add(getJMenuItemStopIdentificationThread());
        jMenuTool.add(getJMenuItemResumeIdentificationThread());

    }
    return jMenuTool;
}

From source file:AltiConsole.AltiConsoleMainScreen.java

/**
 * Constructs main screen of the application.
 * //from  w w w  .  ja va2 s. co m
 * @param title
 *            the frame title.
 */
public AltiConsoleMainScreen(final String title) {

    super(title);
    trans = Application.getTranslator();

    // //////// Menu code starts her //////////////
    // File
    fileMenu = new JMenu();
    fileMenu.setText(trans.get("AltiConsoleMainScreen.File"));

    // Load data
    loadDataMenuItem = new JMenuItem();
    loadDataMenuItem.setText(trans.get("AltiConsoleMainScreen.RetrieveFlightData"));
    loadDataMenuItem.setActionCommand("RETRIEVE_FLIGHT");
    loadDataMenuItem.addActionListener(this);

    eraseAllDataMenuItem = new JMenuItem();
    eraseAllDataMenuItem.setText(trans.get("AltiConsoleMainScreen.EraseFlightData"));
    eraseAllDataMenuItem.setActionCommand("ERASE_FLIGHT");
    eraseAllDataMenuItem.addActionListener(this);

    // Save as
    saveASMenuItem = new JMenuItem();
    saveASMenuItem.setText(trans.get("AltiConsoleMainScreen.saveFlightData"));
    saveASMenuItem.setActionCommand("SAVE_FLIGHT");
    saveASMenuItem.addActionListener(this);

    // Exit
    exitMenuItem = new JMenuItem();
    exitMenuItem.setText(trans.get("AltiConsoleMainScreen.Exit"));
    exitMenuItem.setActionCommand("EXIT");
    exitMenuItem.addActionListener(this);

    fileMenu.add(saveASMenuItem);

    fileMenu.add(loadDataMenuItem);
    fileMenu.add(eraseAllDataMenuItem);
    fileMenu.add(exitMenuItem);

    // Option menu
    optionMenu = new JMenu(trans.get("AltiConsoleMainScreen.Option"));
    preferencesMenuItem = new JMenuItem(trans.get("AltiConsoleMainScreen.Preferences"));
    preferencesMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("pref\n");
            Preferences.showPreferences(AltiConsoleMainScreen.this);
            //LicenseDialog.showPreferences(AltiConsoleMainScreen.this);
            System.out.println("change units\n");
            String Units;
            System.out.println(UserPref.getAppUnits());
            if (Utils.equals(UserPref.getAppUnits(), "Unit.Metrics"))
                Units = trans.get("Unit.Metrics");
            else
                Units = trans.get("Unit.Imperial");

            chart.getXYPlot().getRangeAxis()
                    .setLabel(trans.get("AltiConsoleMainScreen.altitude") + " (" + Units + ")");
            if (Serial.getConnected()) {
                RetrievingFlight();
            }

        }
    });

    optionMenu.add(preferencesMenuItem);

    // Configuration menu
    altiConfigMenu = new JMenu(trans.get("AltiConsoleMainScreen.ConfigAltimeter"));

    retrieveAltiConfigMenuItem = new JMenuItem(trans.get("AltiConsoleMainScreen.RetrieveAltiConfig"));
    retrieveAltiConfigMenuItem.setActionCommand("RETRIEVE_ALTI_CFG");
    retrieveAltiConfigMenuItem.addActionListener(this);
    altiConfigMenu.add(retrieveAltiConfigMenuItem);

    uploadFirmwareMenuItem = new JMenuItem(trans.get("AltiConsoleMainScreen.UploadFirmware"));

    uploadFirmwareMenuItem.setActionCommand("UPLOAD_FIRMWARE");
    uploadFirmwareMenuItem.addActionListener(this);
    altiConfigMenu.add(uploadFirmwareMenuItem);

    // Help
    helpMenu = new JMenu(trans.get("AltiConsoleMainScreen.Help"));
    jJMenuBar = new JMenuBar();

    // Manual
    onLineHelpMenuItem = new JMenuItem(trans.get("AltiConsoleMainScreen.onLineHelp"));
    onLineHelpMenuItem.setActionCommand("ON_LINE_HELP");
    onLineHelpMenuItem.addActionListener(this);

    // license
    licenseMenuItem = new JMenuItem(trans.get("AltiConsoleMainScreen.license"));
    licenseMenuItem.setActionCommand("LICENSE");
    licenseMenuItem.addActionListener(this);

    // AboutScreen
    aboutMenuItem = new JMenuItem();
    aboutMenuItem.setText(trans.get("AltiConsoleMainScreen.About"));
    aboutMenuItem.setActionCommand("ABOUT");
    aboutMenuItem.addActionListener(this);

    helpMenu.add(onLineHelpMenuItem);
    helpMenu.add(licenseMenuItem);
    helpMenu.add(aboutMenuItem);

    jJMenuBar.add(fileMenu);
    jJMenuBar.add(optionMenu);
    jJMenuBar.add(altiConfigMenu);
    jJMenuBar.add(helpMenu);
    this.setJMenuBar(jJMenuBar);

    // ///// end of Menu code

    // Button
    retrieveFlights = new JButton();
    retrieveFlights.setText(trans.get("AltiConsoleMainScreen.RetrieveFlights"));
    retrieveFlights.setActionCommand("RETRIEVE_FLIGHT");
    retrieveFlights.addActionListener(this);
    retrieveFlights.setToolTipText(trans.get("AltiConsoleMainScreen.ttipRetrieveFlight"));

    // combo serial rate
    String[] serialRateStrings = { "300", "1200", "2400", "4800", "9600", "14400", "19200", "28800", "38400",
            "57600", "115200" };

    serialRatesLabel = new JLabel(trans.get("AltiConsoleMainScreen.comPortSpeed") + " ");
    serialRates = new JComboBox();
    System.out.println(UserPref.getDefComSpeed() + "\n");
    for (int i = 0; i < serialRateStrings.length; i++) {
        serialRates.addItem(serialRateStrings[i]);

        if (Utils.equals(UserPref.getDefComSpeed(), serialRateStrings[i])) {
            serialRates.setSelectedIndex(i);
        }
    }
    serialRates.setToolTipText(trans.get("AltiConsoleMainScreen.ttipChoosePortSpeed"));

    comPortsLabel = new JLabel(trans.get("AltiConsoleMainScreen.port") + " ");
    comPorts = new JComboBox();

    comPorts.setActionCommand("comPorts");
    comPorts.addActionListener(this);
    comPorts.setToolTipText(trans.get("AltiConsoleMainScreen.ttipChooseAltiport"));
    listData = new DefaultListModel();

    flightList = new JXList(listData);
    flightList.addListSelectionListener(new ValueReporter());

    JPanel TopPanelLeft = new JPanel();
    TopPanelLeft.setLayout(new BorderLayout());
    TopPanelLeft.add(comPortsLabel, BorderLayout.WEST);
    TopPanelLeft.add(comPorts, BorderLayout.EAST);

    JPanel TopPanelMiddle = new JPanel();
    TopPanelMiddle.setLayout(new BorderLayout());
    TopPanelMiddle.add(retrieveFlights, BorderLayout.WEST);

    JPanel TopPanelRight = new JPanel();
    TopPanelRight.setLayout(new BorderLayout());
    TopPanelRight.add(serialRatesLabel, BorderLayout.WEST);
    TopPanelRight.add(serialRates, BorderLayout.EAST);

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

    TopPanel.add(TopPanelRight, BorderLayout.EAST);
    TopPanel.add(TopPanelMiddle, BorderLayout.CENTER);
    TopPanel.add(TopPanelLeft, BorderLayout.WEST);
    JPanel MiddlePanel = new JPanel();
    MiddlePanel.setLayout(new BorderLayout());

    MiddlePanel.add(TopPanel, BorderLayout.NORTH);
    MiddlePanel.add(flightList, BorderLayout.WEST);

    String Units;
    if (Utils.equals(UserPref.getAppUnits(), "Unit.Metrics"))
        Units = trans.get("Unit.Metrics");
    else
        Units = trans.get("Unit.Imperial");

    chart = ChartFactory.createXYLineChart(trans.get("AltiConsoleMainScreen.Title"),
            trans.get("AltiConsoleMainScreen.time"),
            trans.get("AltiConsoleMainScreen.altitude") + " (" + Units + ")", null);

    chart.setBackgroundPaint(Color.white);
    System.out.println(chart.getSubtitle(0));

    this.plot = chart.getXYPlot();
    this.plot.setBackgroundPaint(Color.lightGray);
    this.plot.setDomainGridlinePaint(Color.white);
    this.plot.setRangeGridlinePaint(Color.white);

    final ValueAxis axis = this.plot.getDomainAxis();
    axis.setAutoRange(true);

    final NumberAxis rangeAxis2 = new NumberAxis("Range Axis 2");
    rangeAxis2.setAutoRangeIncludesZero(false);

    final ChartPanel chartPanel = new ChartPanel(chart);

    MiddlePanel.add(chartPanel, BorderLayout.CENTER);

    JPanel InfoPanel = new JPanel(new MigLayout("fill"));
    InfoPanel.add(new JLabel(trans.get("AltiConsoleMainScreen.ApogeeAltitude")), "gapright para");
    apogeeAltitudeLabel = new JLabel();
    InfoPanel.add(apogeeAltitudeLabel, "growx");
    InfoPanel.add(new JLabel(trans.get("AltiConsoleMainScreen.MainAltitude")), "gapright para");
    mainAltitudeLabel = new JLabel();
    InfoPanel.add(mainAltitudeLabel, "growx");
    flightNbrLabel = new JLabel();

    InfoPanel.add(new JLabel(trans.get("AltiConsoleMainScreen.NbrOfPoint")), "growx");
    nbrPointLabel = new JLabel();
    InfoPanel.add(nbrPointLabel, "wrap rel,growx");

    txtLog = new JTextArea(5, 70);
    txtLog.setEditable(false);
    txtLog.setAutoscrolls(true);

    scrollPane = new JScrollPane(txtLog);
    scrollPane.setAutoscrolls(true);
    // BottomPanel.add(scrollPane, BorderLayout.WEST);
    InfoPanel.add(scrollPane, "span");
    // MiddlePanel.add(BottomPanel, BorderLayout.SOUTH);
    MiddlePanel.add(InfoPanel, BorderLayout.SOUTH);
    setContentPane(MiddlePanel);
    try {
        try {
            Serial = new AltimeterSerial(this);

            Serial.searchForPorts();
        } catch (UnsatisfiedLinkError e) {
            System.out.println("USB Library rxtxSerial.dll Not Found");
            System.out.println("Exception:" + e.toString() + ":" + e.getMessage());
            System.out.println(e.toString());
            JOptionPane.showMessageDialog(null,
                    "You must copy the appropriate rxtxSerial.dll \n "
                            + "to your local 32 bit or 64 bitjava JRE installation\n\n"
                            + " .../arduino-1.0.1-windows/arduino-1.0.1/rxtxSerial.dll\n"
                            + "to\n C:/Program Files (x86)/Java/jre7/bin/rxtxSerial.dll\n"
                            + "also right click Properties->Unblock",
                    trans.get("AltiConsoleMainScreen.InstallationProblem"), JOptionPane.WARNING_MESSAGE);
        }
    } catch (NoClassDefFoundError e) {
        System.out.println("Missing RXTXcomm.jar in java installation");
        System.out.println("Exception:" + e.toString() + ":" + e.getMessage());
        System.out.println(e.toString());
        JOptionPane.showMessageDialog(null,
                "You must copy RXTXcomm.jar from the Arduino software\n "
                        + "to your local 32 bit java JRE installation\n\n"
                        + " .../arduino-1.0.1-windows/arduino-1.0.1/lib/RXTXcomm.jar\n"
                        + "to\n C:/Program Files (x86)/Java/jre7/lib/ext/RXTXcomm.jar\n"
                        + "also right click Properties->Unblock",
                trans.get("AltiConsoleMainScreen.InstallationProblem"), JOptionPane.WARNING_MESSAGE);
    }
}

From source file:org.sbml.bargraph.MainWindow.java

/**
 * Creates the main application frame./*  ww w.j  a v a 2 s. c  om*/
 * 
 * @param file A file to read and graph upon start up.  If null, nothing
 * is graphed initially.
 */
public MainWindow(File file) {
    Log.note("Creating main application window.");
    setPlatformProperties();

    setBackground(new Color(255, 255, 255));
    setMaximumSize(new Dimension(2000, 1000));
    setMinimumSize(new Dimension(600, 400));
    setTitle("SBML Bar Graph");
    setSize(new Dimension(600, 400));
    setPreferredSize(new Dimension(600, 400));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 550, 400);
    contentPane = new JPanel();
    contentPane.setSize(new Dimension(600, 400));
    contentPane.setPreferredSize(new Dimension(600, 400));
    contentPane.setMinimumSize(new Dimension(600, 400));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    fileNamePanel = new JPanel();
    fileNamePanel.setPreferredSize(new Dimension(590, 20));
    fileNamePanel.setMinimumSize(new Dimension(590, 20));
    fileNamePanel.setLayout(new BorderLayout(0, 0));
    contentPane.add(fileNamePanel, BorderLayout.NORTH);

    fileNameField = new JTextField();
    fileNameField.setHorizontalAlignment(SwingConstants.CENTER);
    fileNameField.setText("No file selected");
    fileNameField.setDisabledTextColor(Color.LIGHT_GRAY);
    fileNameField.setFont(new Font("Lucida Grande", Font.ITALIC, 11));
    fileNameField.setBorder(null);
    fileNameField.setOpaque(true);
    fileNameField.setBackground(UIManager.getColor("Separator.foreground"));
    fileNameField.setEnabled(false);
    fileNameField.setSize(new Dimension(590, 0));
    fileNameField.setPreferredSize(new Dimension(590, 28));
    fileNameField.setMinimumSize(new Dimension(590, 28));
    fileNameField.setColumns(10);
    fileNamePanel.add(fileNameField, BorderLayout.CENTER);

    // The bar graph panel.

    chartPanel = new ChartPanel(createModelBarGraph(), false);
    contentPane.add(chartPanel, BorderLayout.CENTER);
    updatePanelForSBMLFile(file);

    // Manual additions for File menu.

    fileMenu = new JMenu();
    fileMenu.setText("File");

    openFileMenuItem = new JMenuItem();
    openFileMenuItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, shortcutKeyMask));
    openFileMenuItem.setText("Open...");
    openFileMenuItem.setToolTipText("Open file to be graphed");
    openFileMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            openFileHandler(evt);
        }
    });

    fileMenu.add(openFileMenuItem);
    menuBar = new javax.swing.JMenuBar();
    menuBar.add(fileMenu);

    setJMenuBar(menuBar);

    // Replace the default Java window icon with our own.
    // This only has an effect on non-Mac OS systems.

    URL iconImageURL = getClass().getResource(Config.RES_ICON_APP);
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Image img = toolkit.createImage(iconImageURL);
    setIconImage(img);

    Log.note("Finished constructing panel and menu bar");
}

From source file:gtu._work.ui.PropertyEditUI.java

private void initGUI() {
    try {/*from   w  ww.j ava 2  s . c  om*/
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        BorderLayout thisLayout = new BorderLayout();
        this.setTitle("PropertyEditUI");
        getContentPane().setLayout(thisLayout);
        {
            jMenuBar1 = new JMenuBar();
            setJMenuBar(jMenuBar1);
            {
                jMenu1 = new JMenu();
                jMenuBar1.add(jMenu1);
                jMenu1.setText("File");
                {
                    jMenuItem1 = new JMenuItem();
                    jMenu1.add(jMenuItem1);
                    jMenuItem1.setText("open directory");
                    jMenuItem1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JCommonUtil._jFileChooser_selectDirectoryOnly();
                            loadCurrentFile(file);
                        }
                    });
                }
                {
                    openDirectoryAndChildren = new JMenuItem();
                    jMenu1.add(openDirectoryAndChildren);
                    openDirectoryAndChildren.setText("open directory and children");
                    openDirectoryAndChildren.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            System.out.println("openDirectoryAndChildren.actionPerformed, event=" + evt);
                            File file = JCommonUtil._jFileChooser_selectDirectoryOnly();
                            if (file == null) {
                                // file =
                                // PropertiesUtil.getJarCurrentPath(getClass());//XXX
                                file = new File("D:\\my_tool\\english");
                                JCommonUtil._jOptionPane_showMessageDialog_info("load C:\\L-CONFIG !");
                            }
                            DefaultListModel model = new DefaultListModel();
                            List<File> list = new ArrayList<File>();
                            FileUtil.searchFileMatchs(file, ".*\\.properties", list);
                            for (File f : list) {
                                File_ ff = new File_();
                                ff.file = f;
                                model.addElement(ff);
                            }
                            backupFileList = list;
                            fileList.setModel(model);
                        }
                    });
                }
                {
                    jMenuItem2 = new JMenuItem();
                    jMenu1.add(jMenuItem2);
                    jMenuItem2.setText("save");
                    jMenuItem2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            System.out.println("jMenu3.actionPerformed, event=" + evt);
                            if (currentFile == null) {
                                return;
                            }
                            if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                    "save to " + currentFile.getName(), "SAVE")) {
                                try {
                                    Properties prop = new Properties();
                                    // try {
                                    // prop.load(new
                                    // FileInputStream(currentFile));
                                    // } catch (Exception e) {
                                    // e.printStackTrace();
                                    // JCommonUtil.handleException(e);
                                    // return;
                                    // }
                                    loadModelToProperties(prop);
                                    prop.store(new FileOutputStream(currentFile), getTitle());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    JCommonUtil.handleException(e);
                                }
                            }
                        }
                    });
                }
                {
                    jMenuItem3 = new JMenuItem();
                    jMenu1.add(jMenuItem3);
                    jMenuItem3.setText("save to target");
                    jMenuItem3.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectFileOnly().showSaveDialog()
                                    .getApproveSelectedFile();
                            if (file == null) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("file name is not correct!");
                                return;
                            }
                            if (!file.getName().contains(".properties")) {
                                file = new File(file.getParent(), file.getName() + ".properties");
                            }
                            try {
                                Properties prop = new Properties();
                                // try {
                                // prop.load(new
                                // FileInputStream(currentFile));
                                // } catch (Exception e) {
                                // e.printStackTrace();
                                // JCommonUtil.handleException(e);
                                // return;
                                // }
                                loadModelToProperties(prop);
                                prop.store(new FileOutputStream(file), getTitle());
                            } catch (Exception e) {
                                e.printStackTrace();
                                JCommonUtil.handleException(e);
                            }
                        }
                    });
                }
                {
                    jMenuItem4 = new JMenuItem();
                    jMenu1.add(jMenuItem4);
                    jMenuItem4.setText("save file(sorted)");
                    jMenuItem4.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            if (currentFile == null) {
                                return;
                            }
                            try {
                                BufferedReader reader = new BufferedReader(
                                        new InputStreamReader(new FileInputStream(currentFile)));
                                List<String> sortList = new ArrayList<String>();
                                for (String line = null; (line = reader.readLine()) != null;) {
                                    sortList.add(line);
                                }
                                reader.close();
                                Collections.sort(sortList);
                                StringBuilder sb = new StringBuilder();
                                for (String line : sortList) {
                                    sb.append(line + "\n");
                                }
                                FileUtil.saveToFile(currentFile, sb.toString(), "UTF8");
                            } catch (FileNotFoundException e) {
                                e.printStackTrace();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                }
                {
                    jMenuItem5 = new JMenuItem();
                    jMenu1.add(jMenuItem5);
                    jMenuItem5.setText("");
                    jMenuItem5.addActionListener(new ActionListener() {
                        private void setMeaning(String meaning, int rowPos) {
                            propTable.getRowSorter().getModel().setValueAt(meaning, rowPos, 2);
                        }

                        private void setMeaningEn1(String english, int rowPos, List<String> errSb) {
                            EnglishTester_Diectory eng = new EnglishTester_Diectory();
                            try {
                                WordInfo wordInfo = eng.parseToWordInfo(english);
                                String meaning = getChs2Big5(wordInfo.getMeaning());
                                if (hasChinese(meaning)) {
                                    setMeaning(meaning, rowPos);
                                } else {
                                    setMeaningEn2(english, rowPos, errSb);
                                }
                            } catch (Exception e) {
                                errSb.add(english);
                                e.printStackTrace();
                            }
                        }

                        private void setMeaningEn2(String english, int rowPos, List<String> errSb) {
                            EnglishTester_Diectory2 eng2 = new EnglishTester_Diectory2();
                            try {
                                WordInfo2 wordInfo = eng2.parseToWordInfo(english);
                                String meaning = getChs2Big5(StringUtils.join(wordInfo.getMeaningList(), ";"));
                                setMeaning(meaning, rowPos);
                            } catch (Exception e) {
                                errSb.add(english);
                                e.printStackTrace();
                            }
                        }

                        private boolean hasChinese(String val) {
                            return new StringUtil_().getChineseWord(val, true).length() > 0;
                        }

                        private Properties loadFromMemoryBank() {
                            try {
                                Properties prop = new Properties();
                                File f1 = new File(
                                        "D:/gtu001_dropbox/Dropbox/Apps/gtu001_test/etc_config/EnglishSearchUI_MemoryBank.properties");
                                File f2 = new File(
                                        "e:/gtu001_dropbox/Dropbox/Apps/gtu001_test/etc_config/EnglishSearchUI_MemoryBank.properties");
                                for (File f : new File[] { f1, f2 }) {
                                    if (f.exists()) {
                                        HermannEbbinghaus_Memory memory = new HermannEbbinghaus_Memory();
                                        memory.init(f);
                                        List<MemData> memLst = memory.getAllMemData(true);
                                        for (MemData d : memLst) {
                                            prop.setProperty(d.getKey(), getChs2Big5(d.getRemark()));
                                        }
                                        break;
                                    }
                                }
                                return prop;
                            } catch (Exception ex) {
                                throw new RuntimeException(ex);
                            }
                        }

                        public void actionPerformed(ActionEvent evt) {
                            if (currentFile == null) {
                                return;
                            }

                            // Properties memoryProp = loadFromMemoryBank();
                            Properties memoryProp = new Properties();

                            List<String> errSb = new ArrayList<String>();
                            for (int row = 0; row < propTable.getModel().getRowCount(); row++) {
                                int rowPos = propTable.getRowSorter().convertRowIndexToModel(row);
                                String english = StringUtils.trimToEmpty(
                                        (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 1))
                                        .toLowerCase();
                                String desc = (String) propTable.getRowSorter().getModel().getValueAt(rowPos,
                                        2);

                                if (memoryProp.containsKey(english)
                                        && StringUtils.isNotBlank(memoryProp.getProperty(english))) {
                                    setMeaning(memoryProp.getProperty(english), rowPos);
                                } else {
                                    if (StringUtils.isBlank(desc) || !hasChinese(desc)) {
                                        if (!english.contains(" ")) {
                                            setMeaningEn1(english, rowPos, errSb);
                                        } else {
                                            setMeaningEn2(english, rowPos, errSb);
                                        }
                                    }
                                }

                                if (StringUtils.trimToEmpty(desc).contains("?")) {
                                    setMeaning("", rowPos);
                                }
                            }
                            if (!errSb.isEmpty()) {
                                JCommonUtil._jOptionPane_showMessageDialog_error(":\n" + errSb);
                            }
                        }
                    });
                }

                {
                    JMenuItem jMenuItem6 = new JMenuItem();
                    jMenu1.add(jMenuItem6);
                    jMenuItem6.setText("");
                    jMenuItem6.addActionListener(new ActionListener() {
                        private void setMeaning(String meaning, int rowPos) {
                            propTable.getRowSorter().getModel().setValueAt(meaning, rowPos, 2);
                        }

                        public void actionPerformed(ActionEvent evt) {
                            for (int row = 0; row < propTable.getModel().getRowCount(); row++) {
                                int rowPos = propTable.getRowSorter().convertRowIndexToModel(row);
                                String english = StringUtils.trimToEmpty(
                                        (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 1))
                                        .toLowerCase();
                                String desc = (String) propTable.getRowSorter().getModel().getValueAt(rowPos,
                                        2);

                                if (StringUtils.trimToEmpty(desc).contains("?")) {
                                    setMeaning("", rowPos);
                                }
                            }
                        }
                    });
                }
            }
        }
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("editor", null, jPanel2, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel2.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(550, 314));
                    {
                        TableModel propTableModel = new DefaultTableModel(
                                new String[][] { { "", "", "" }, { "", "", "" } },
                                new String[] { "index", "Key", "value" });
                        propTable = new JTable();
                        JTableUtil.defaultSetting_AutoResize(propTable);
                        jScrollPane1.setViewportView(propTable);
                        propTable.setModel(propTableModel);
                        propTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                JTableUtil xxxxxx = JTableUtil.newInstance(propTable);
                                int[] rows = xxxxxx.getSelectedRows();
                                for (int ii : rows) {
                                    System.out.println(xxxxxx.getModel().getValueAt(ii, 1));
                                }
                                JPopupMenuUtil.newInstance(propTable).applyEvent(evt)
                                        .addJMenuItem(JTableUtil.newInstance(propTable).getDefaultJMenuItems())
                                        .show();
                            }
                        });
                    }
                }
                {
                    queryText = new JTextField();
                    jPanel2.add(queryText, BorderLayout.NORTH);
                    queryText.getDocument()
                            .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {

                                @Override
                                public void process(DocumentEvent event) {
                                    if (currentFile == null) {
                                        return;
                                    }
                                    Properties prop = new Properties();
                                    try {
                                        prop.load(new FileInputStream(currentFile));
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                        JCommonUtil.handleException(e);
                                        return;
                                    }
                                    loadPropertiesToModel(prop);
                                    String text = JCommonUtil.getDocumentText(event);
                                    Pattern pattern = null;
                                    try {
                                        pattern = Pattern.compile(text);
                                    } catch (Exception ex) {
                                    }

                                    DefaultTableModel model = JTableUtil.newInstance(propTable).getModel();
                                    for (int ii = 0; ii < model.getRowCount(); ii++) {
                                        String key = (String) model.getValueAt(ii, 1);
                                        String value = (String) model.getValueAt(ii, 2);
                                        if (key.contains(text)) {
                                            continue;
                                        }
                                        if (value.contains(text)) {
                                            continue;
                                        }
                                        if (pattern != null) {
                                            if (pattern.matcher(key).find()) {
                                                continue;
                                            }
                                            if (pattern.matcher(value).find()) {
                                                continue;
                                            }
                                        }
                                        model.removeRow(propTable.convertRowIndexToModel(ii));
                                        ii--;
                                    }
                                }
                            }));
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jTabbedPane1.addTab("folder", null, jPanel3, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel3.add(jScrollPane2, BorderLayout.CENTER);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(550, 314));
                    {
                        fileList = new JList();
                        jScrollPane2.setViewportView(fileList);
                        fileList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                JListUtil.newInstance(fileList).defaultJListKeyPressed(evt);
                            }
                        });
                        fileList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                final File_ file = JListUtil.getLeadSelectionObject(fileList);

                                if (evt.getButton() == MouseEvent.BUTTON1) {
                                    Properties prop = new Properties();
                                    currentFile = file.file;
                                    setTitle(currentFile.getName());
                                    try {
                                        prop.load(new FileInputStream(file.file));
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                    loadPropertiesToModel(prop);
                                }

                                if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) {
                                    try {
                                        Runtime.getRuntime().exec(String.format("cmd /c \"%s\"", file.file));
                                    } catch (IOException e1) {
                                        e1.printStackTrace();
                                    }
                                }

                                final File parent = file.file.getParentFile();
                                JMenuItem openTargetDir = new JMenuItem();
                                openTargetDir.setText("open : " + parent);
                                openTargetDir.addActionListener(new ActionListener() {
                                    @Override
                                    public void actionPerformed(ActionEvent e) {
                                        try {
                                            Desktop.getDesktop().open(parent);
                                        } catch (IOException e1) {
                                            JCommonUtil.handleException(e1);
                                        }
                                    }
                                });

                                JPopupMenuUtil.newInstance(fileList).addJMenuItem(openTargetDir).applyEvent(evt)
                                        .show();
                            }
                        });
                    }
                }
                {
                    fileQueryText = new JTextField();
                    jPanel3.add(fileQueryText, BorderLayout.NORTH);
                    fileQueryText.getDocument()
                            .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {
                                @Override
                                public void process(DocumentEvent event) {
                                    String text = JCommonUtil.getDocumentText(event);
                                    DefaultListModel model = new DefaultListModel();
                                    for (File f : backupFileList) {
                                        if (f.getName().contains(text)) {
                                            File_ ff = new File_();
                                            ff.file = f;
                                            model.addElement(ff);
                                        }
                                    }
                                    fileList.setModel(model);
                                }
                            }));
                }
                {
                    contentQueryText = new JTextField();
                    jPanel3.add(contentQueryText, BorderLayout.SOUTH);
                    contentQueryText.addActionListener(new ActionListener() {

                        void addModel(File f, DefaultListModel model) {
                            File_ ff = new File_();
                            ff.file = f;
                            model.addElement(ff);
                        }

                        public void actionPerformed(ActionEvent evt) {
                            DefaultListModel model = new DefaultListModel();
                            String text = contentQueryText.getText();
                            if (StringUtils.isEmpty(contentQueryText.getText())) {
                                return;
                            }
                            Pattern pattern = Pattern.compile(text);
                            Properties pp = null;
                            for (File f : backupFileList) {
                                pp = new Properties();
                                try {
                                    pp.load(new FileInputStream(f));
                                    for (String key : pp.stringPropertyNames()) {
                                        if (key.isEmpty()) {
                                            continue;
                                        }
                                        if (pp.getProperty(key) == null || pp.getProperty(key).isEmpty()) {
                                            continue;
                                        }
                                        if (key.contains(text)) {
                                            addModel(f, model);
                                            break;
                                        }
                                        if (pp.getProperty(key).contains(text)) {
                                            addModel(f, model);
                                            break;
                                        }
                                        if (pattern.matcher(key).find()) {
                                            addModel(f, model);
                                            break;
                                        }
                                        if (pattern.matcher(pp.getProperty(key)).find()) {
                                            addModel(f, model);
                                            break;
                                        }
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            fileList.setModel(model);
                        }
                    });
                }
            }
        }
        JCommonUtil.setJFrameIcon(this, "resource/images/ico/english.ico");
        JCommonUtil.setJFrameCenter(this);
        pack();
        this.setSize(571, 408);

        loadCurrentFile(null);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ec.ui.chart.RevisionChartPanel.java

private JMenu buildMenu() {
    am = new ActionMap();
    am.put(COPY_ACTION, new CopyAction());

    im = new InputMap();
    KeyStrokes.putAll(im, KeyStrokes.COPY, COPY_ACTION);

    JMenu result = new JMenu();

    JMenuItem item;//  w  ww  .j  a v a2 s .c  om

    item = new JMenuItem(am.get(COPY_ACTION));
    item.setText("Copy All");
    item.setAccelerator(KeyStrokes.COPY.get(0));
    ExtAction.hideWhenDisabled(item);
    result.add(item);

    return result;
}

From source file:ec.ui.view.ARPView.java

protected JMenu buildMenu() {
    JMenu result = new JMenu();

    result.add(MatrixChartCommand.copySeries(0, 0).toAction(chartPanel)).setText("Copy series");

    JMenu export = new JMenu("Export image to");
    export.add(ChartCommand.printImage().toAction(chartPanel)).setText("Printer...");
    export.add(ChartCommand.copyImage().toAction(chartPanel)).setText("Clipboard");
    export.add(ChartCommand.saveImage().toAction(chartPanel)).setText("File...");
    result.add(export);/*  w  ww .ja va2  s. com*/

    return result;
}

From source file:fedroot.dacs.swingdemo.DacsSingleFrameApplication.java

private JMenu createMenu(String menuName, String[] actionNames) {
    JMenu menu = new JMenu();
    menu.setName(menuName);//  w  w w .ja v  a 2 s . com
    for (String actionName : actionNames) {
        JMenuItem menuItem = new JMenuItem();
        menuItem.setAction(actionMap().get(actionName));
        menu.add(menuItem);
    }
    return menu;
}

From source file:net.sf.jabref.gui.RightClickMenu.java

public RightClickMenu(BasePanel panel_, MetaData metaData_) {
    panel = panel_;//from w  w  w.ja v a  2  s  .c o  m
    metaData = metaData_;
    JMenu typeMenu = ChangeEntryTypeMenu.getChangeEntryTypeMenu(panel);
    // Are multiple entries selected?
    boolean multiple = panel.mainTable.getSelectedRowCount() > 1;

    // If only one entry is selected, get a reference to it for adapting the menu.
    BibEntry be = null;
    if (panel.mainTable.getSelectedRowCount() == 1) {
        be = panel.mainTable.getSelected().get(0);
    }

    addPopupMenuListener(this);

    add(new GeneralAction(Actions.COPY, Localization.lang("Copy"), IconTheme.JabRefIcon.COPY.getSmallIcon()));
    add(new GeneralAction(Actions.PASTE, Localization.lang("Paste"),
            IconTheme.JabRefIcon.PASTE.getSmallIcon()));
    add(new GeneralAction(Actions.CUT, Localization.lang("Cut"), IconTheme.JabRefIcon.CUT.getSmallIcon()));
    add(new GeneralAction(Actions.DELETE, Localization.lang("Delete"),
            IconTheme.JabRefIcon.DELETE_ENTRY.getSmallIcon()));
    addSeparator();

    add(new GeneralAction(Actions.COPY_KEY, Localization.lang("Copy BibTeX key")));
    add(new GeneralAction(Actions.COPY_CITE_KEY, Localization.lang("Copy \\cite{BibTeX key}")));
    add(new GeneralAction(Actions.COPY_KEY_AND_TITLE, Localization.lang("Copy BibTeX key and title")));

    add(new GeneralAction(Actions.EXPORT_TO_CLIPBOARD, Localization.lang("Export to clipboard"),
            IconTheme.JabRefIcon.EXPORT_TO_CLIPBOARD.getSmallIcon()));
    add(new GeneralAction(Actions.SEND_AS_EMAIL, Localization.lang("Send as email"),
            IconTheme.JabRefIcon.EMAIL.getSmallIcon()));
    addSeparator();

    JMenu markSpecific = JabRefFrame.subMenu("Mark specific color");
    JabRefFrame frame = JabRef.jrf;
    for (int i = 0; i < EntryMarker.MAX_MARKING_LEVEL; i++) {
        markSpecific.add(new MarkEntriesAction(frame, i).getMenuItem());
    }

    if (multiple) {
        add(new GeneralAction(Actions.MARK_ENTRIES, Localization.lang("Mark entries"),
                IconTheme.JabRefIcon.MARK_ENTRIES.getSmallIcon()));
        add(markSpecific);
        add(new GeneralAction(Actions.UNMARK_ENTRIES, Localization.lang("Unmark entries"),
                IconTheme.JabRefIcon.UNMARK_ENTRIES.getSmallIcon()));
        addSeparator();
    } else if (be != null) {
        String marked = be.getField(BibtexFields.MARKED);
        // We have to check for "" too as the marked field may be empty
        if ((marked == null) || marked.isEmpty()) {
            add(new GeneralAction(Actions.MARK_ENTRIES, Localization.lang("Mark entry"),
                    IconTheme.JabRefIcon.MARK_ENTRIES.getSmallIcon()));
            add(markSpecific);
        } else {
            add(markSpecific);
            add(new GeneralAction(Actions.UNMARK_ENTRIES, Localization.lang("Unmark entry"),
                    IconTheme.JabRefIcon.UNMARK_ENTRIES.getSmallIcon()));
        }
        addSeparator();
    }

    if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED)) {
        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING)) {
            JMenu rankingMenu = new JMenu();
            RightClickMenu.populateSpecialFieldMenu(rankingMenu, Rank.getInstance(), JabRef.jrf);
            add(rankingMenu);
        }

        // TODO: multiple handling for relevance and quality-assurance
        // if multiple values are selected ("if (multiple)"), two options (set / clear) should be offered
        // if one value is selected either set or clear should be offered
        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE)) {
            add(Relevance.getInstance().getValues().get(0).getMenuAction(JabRef.jrf));
        }
        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY)) {
            add(Quality.getInstance().getValues().get(0).getMenuAction(JabRef.jrf));
        }
        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRINTED)) {
            add(Printed.getInstance().getValues().get(0).getMenuAction(JabRef.jrf));
        }

        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY)) {
            JMenu priorityMenu = new JMenu();
            RightClickMenu.populateSpecialFieldMenu(priorityMenu, Priority.getInstance(), JabRef.jrf);
            add(priorityMenu);
        }

        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_READ)) {
            JMenu readStatusMenu = new JMenu();
            RightClickMenu.populateSpecialFieldMenu(readStatusMenu, ReadStatus.getInstance(), JabRef.jrf);
            add(readStatusMenu);
        }

        addSeparator();
    }

    add(new GeneralAction(Actions.OPEN_FOLDER, Localization.lang("Open folder")) {
        {
            if (!isFieldSetForSelectedEntry("file")) {
                this.setEnabled(false);
            }
        }
    });

    add(new GeneralAction(Actions.OPEN_EXTERNAL_FILE, Localization.lang("Open file"),
            getFileIconForSelectedEntry()) {
        {
            if (!isFieldSetForSelectedEntry("file")) {
                this.setEnabled(false);
            }
        }
    });

    add(new GeneralAction(Actions.ADD_FILE_LINK, Localization.lang("Attach file"),
            IconTheme.JabRefIcon.ATTACH_FILE.getSmallIcon()));

    add(new GeneralAction(Actions.OPEN_URL, Localization.lang("Open URL or DOI"),
            IconTheme.JabRefIcon.WWW.getSmallIcon()) {
        {
            if (!(isFieldSetForSelectedEntry("url") || isFieldSetForSelectedEntry("doi"))) {
                this.setEnabled(false);
            }
        }
    });

    add(new GeneralAction(Actions.MERGE_DOI, Localization.lang("Get BibTeX data from DOI")) {
        {
            if (!(isFieldSetForSelectedEntry("doi"))) {
                this.setEnabled(false);
            }
        }
    });

    addSeparator();

    add(typeMenu);
    add(new GeneralAction(Actions.PLAIN_TEXT_IMPORT, Localization.lang("Plain text import")));

    add(JabRef.jrf.massSetField);
    add(JabRef.jrf.manageKeywords);

    addSeparator(); // for "add/move/remove to/from group" entries (appended here)

    groupAdd = new JMenuItem(new GeneralAction(Actions.ADD_TO_GROUP, Localization.lang("Add to group")));
    add(groupAdd);
    groupRemove = new JMenuItem(
            new GeneralAction(Actions.REMOVE_FROM_GROUP, Localization.lang("Remove from group")));
    add(groupRemove);

    JMenuItem groupMoveTo = add(new GeneralAction(Actions.MOVE_TO_GROUP, Localization.lang("Move to group")));
    add(groupMoveTo);

    floatMarked.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Globals.prefs.putBoolean(JabRefPreferences.FLOAT_MARKED_ENTRIES, floatMarked.isSelected());
            panel.mainTable.refreshSorting(); // Bad remote access
        }
    });

    // create disabledIcons for all menu entries
    frame.createDisabledIconsForMenuEntries(this);
}