List of usage examples for javax.swing JMenuItem setText
@BeanProperty(preferred = true, visualUpdate = true, description = "The button's text.") public void setText(String text)
From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java
/** * creates the antenna menu item if it does not already exists * /* ww w . j a va 2 s. c o m*/ * @return antenna menu */ private JMenu getAntennaMenu() { JMenu antennaMenu = new JMenu(guiText.getString("AntennaMenuItem")); // new antenna JMenuItem newAntennaMenuItem = new JMenuItem(); newAntennaMenuItem.setText(guiText.getString("AddNewAntennaMenuItem")); newAntennaMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { showAddAntennaDialog(); } }); antennaMenu.add(newAntennaMenuItem); return antennaMenu; }
From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java
/** * creates the tag menu item if it does not already exists * /*from w w w .j a va 2 s .c o m*/ * @return tag menu */ private JMenu getTagMenu() { JMenu tagMenu = new JMenu(guiText.getString("TagMenuItem")); // new tag JMenuItem newTagMenuItem = new JMenuItem(); newTagMenuItem.setText(guiText.getString("AddNewTagMenuItem")); newTagMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { showAddTagDialog(); } }); tagMenu.add(newTagMenuItem); return tagMenu; }
From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java
/** * creates the help menu item if it does not already exists * /*from w w w . jav a 2 s . c o m*/ * @return help menu */ private JMenu getHelpMenu() { JMenu helpMenu = new JMenu(guiText.getString("HelpMenuItem")); // about JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(guiText.getString("AboutMenuItem")); aboutMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { JDialog aboutDialog = new JDialog(GraphicSimulator.this, guiText.getString("AboutDialogTitle"), true); Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; aboutDialog.setLocation(pos); aboutDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); aboutDialog.setTitle(guiText.getString("AboutDialogTitle")); JLabel text = new JLabel(guiText.getString("AboutDialogContent")); text.setHorizontalAlignment(JLabel.CENTER); aboutDialog.add(text); aboutDialog.setVisible(true); } }); helpMenu.add(aboutMenuItem); return helpMenu; }
From source file:org.accada.reader.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * creates the view menu item//w ww.j av a 2 s. c om * * @return view menu */ private JMenu getViewMenu() { JMenu viewMenu = new JMenu(guiText.getString("ViewMenuItem")); // exit JMenuItem refreshMenuItem = new JMenuItem(); refreshMenuItem.setText(guiText.getString("RefreshMenuItem")); refreshMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { updateGUI(); } }); viewMenu.add(refreshMenuItem); return viewMenu; }
From source file:org.accada.reader.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * creates the help menu item//from w w w. ja v a2s. co m * * @return help menu */ private JMenu getHelpMenu() { JMenu helpMenu = new JMenu(guiText.getString("HelpMenuItem")); // about JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(guiText.getString("AboutMenuItem")); aboutMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { JDialog aboutDialog = new JDialog(GraphicSimulatorServer.this, guiText.getString("AboutDialogTitle"), true); Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; aboutDialog.setLocation(pos); aboutDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); aboutDialog.setTitle(guiText.getString("AboutDialogTitle")); JLabel text = new JLabel(guiText.getString("AboutDialogContent")); text.setHorizontalAlignment(JLabel.CENTER); aboutDialog.add(text); aboutDialog.setVisible(true); } }); helpMenu.add(aboutMenuItem); return helpMenu; }
From source file:org.broad.igv.hic.MainWindow.java
private JMenuBar createMenuBar(final JPanel hiCPanel) { JMenuBar menuBar = new JMenuBar(); //======== fileMenu ======== JMenu fileMenu = new JMenu("File"); //---- loadMenuItem ---- JMenuItem loadMenuItem = new JMenuItem(); loadMenuItem.setText("Load..."); loadMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { loadMenuItemActionPerformed(e); }// w ww.j av a2s . co m }); fileMenu.add(loadMenuItem); //---- loadFromURL ---- JMenuItem loadFromURL = new JMenuItem(); JMenuItem getEigenvector = new JMenuItem(); final JCheckBoxMenuItem viewDNAseI; loadFromURL.setText("Load from URL ..."); loadFromURL.setName("loadFromURL"); loadFromURL.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { loadFromURLActionPerformed(e); } }); fileMenu.add(loadFromURL); fileMenu.addSeparator(); // Pre-defined datasets. TODO -- generate from a file addPredefinedLoadItems(fileMenu); JMenuItem saveToImage = new JMenuItem(); saveToImage.setText("Save to image"); saveToImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { BufferedImage image = (BufferedImage) createImage(1000, 1000); Graphics g = image.createGraphics(); hiCPanel.paint(g); JFileChooser fc = new JFileChooser(); fc.setSelectedFile(new File("image.png")); int actionDialog = fc.showSaveDialog(null); if (actionDialog == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); if (file.exists()) { actionDialog = JOptionPane.showConfirmDialog(null, "Replace existing file?"); if (actionDialog == JOptionPane.NO_OPTION || actionDialog == JOptionPane.CANCEL_OPTION) return; } try { // default if they give no format or invalid format String fmt = "jpg"; int ind = file.getName().indexOf("."); if (ind != -1) { String ext = file.getName().substring(ind + 1); String[] strs = ImageIO.getWriterFormatNames(); for (String aStr : strs) if (ext.equals(aStr)) fmt = ext; } ImageIO.write(image.getSubimage(0, 0, 600, 600), fmt, file); } catch (IOException ie) { System.err.println("Unable to write " + file + ": " + ie); } } } }); fileMenu.add(saveToImage); getEigenvector = new JMenuItem("Get principal eigenvector"); getEigenvector.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getEigenvectorActionPerformed(e); } }); fileMenu.add(getEigenvector); //---- exit ---- JMenuItem exit = new JMenuItem(); exit.setText("Exit"); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exitActionPerformed(e); } }); fileMenu.add(exit); menuBar.add(fileMenu); //======== Tracks menu ======== JMenu tracksMenu = new JMenu("Tracks"); viewEigenvector = new JCheckBoxMenuItem("View Eigenvector..."); viewEigenvector.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (viewEigenvector.isSelected()) { if (eigenvectorTrack == null) { eigenvectorTrack = new EigenvectorTrack("eigen", "Eigenvectors"); } updateEigenvectorTrack(); } else { trackPanel.setEigenvectorTrack(null); if (HiCTrackManager.getLoadedTracks().isEmpty()) { trackPanel.setVisible(false); } } } }); viewEigenvector.setEnabled(false); tracksMenu.add(viewEigenvector); JMenuItem loadItem = new JMenuItem("Load..."); loadItem.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { HiCTrackManager.loadHostedTrack(MainWindow.this); } }); tracksMenu.add(loadItem); JMenuItem loadFromFileItem = new JMenuItem("Load from file..."); loadFromFileItem.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { HiCTrackManager.loadTrackFromFile(MainWindow.this); } }); tracksMenu.add(loadFromFileItem); menuBar.add(tracksMenu); //======== Extras menu ======== JMenu extrasMenu = new JMenu("Extras"); JMenuItem dumpPearsons = new JMenuItem("Dump pearsons matrix ..."); dumpPearsons.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { BasicMatrix pearsons = hic.zd.getPearsons(); try { String chr1 = hic.getChromosomes()[hic.zd.getChr1()].getName(); String chr2 = hic.getChromosomes()[hic.zd.getChr2()].getName(); int binSize = hic.zd.getBinSize(); File initFile = new File("pearsons_" + chr1 + "_" + "_" + chr2 + "_" + binSize + ".bin"); File f = FileDialogUtils.chooseFile("Save pearsons", null, initFile, FileDialogUtils.SAVE); if (f != null) { ScratchPad.dumpPearsonsBinary(pearsons, chr1, chr2, hic.zd.getBinSize(), f); } } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } }); JMenuItem dumpEigenvector = new JMenuItem("Dump eigenvector ..."); dumpEigenvector.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { try { ScratchPad.dumpEigenvector(hic); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } }); extrasMenu.add(dumpEigenvector); JMenuItem readPearsons = new JMenuItem("Read pearsons..."); readPearsons.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { try { File f = FileDialogUtils.chooseFile("Pearsons file (Yunfan format)"); if (f != null) { BasicMatrix bm = ScratchPad.readPearsons(f.getAbsolutePath()); hic.zd.setPearsons(bm); } } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } }); extrasMenu.add(readPearsons); extrasMenu.add(dumpPearsons); menuBar.add(extrasMenu); return menuBar; }
From source file:org.datavyu.views.DatavyuView.java
/** * Creates a new menu item for running a named script. * * @param f//ww w . j av a 2s .c o m * The file to run when menu item is selected. * @return The jmenuitem that can be added to a menu. */ public JMenuItem createScriptMenuItemFromFile(final File f) { JMenuItem menuItem = new JMenuItem(); menuItem.setText(f.toString()); menuItem.setName(f.toString()); menuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { runRecentScript(evt); } }); return menuItem; }
From source file:org.datavyu.views.DatavyuView.java
/** * Creates a new menu item for opening a file. * * @param file//w w w . j a va 2 s .co m * The file to open. * @return The menu item associated with the file. */ private JMenuItem createRecentFileMenuItem(final File file) { JMenuItem menuItem = new JMenuItem(); menuItem.setText(file.toString()); menuItem.setName(file.toString()); menuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { open(file); } }); return menuItem; }
From source file:org.eclipse.birt.chart.device.swing.SwingEventHandler.java
/** * @param muv//from w ww . j a va2 s.c o m * @param point */ private void openMultiULRs(MultiURLValues muv, Point point) { if (popupMenu != null && popupMenu.isValid()) { // Remove previous menu object. popupMenu.setVisible(false); ((JComponent) iun.peerInstance()).remove(popupMenu); } popupMenu = new JPopupMenu(); // Create popup menu items. for (URLValue uv : muv.getURLValues()) { JMenuItem menuItem = new JMenuItem(); popupMenu.add(menuItem); menuItem.setText(uv.getLabel().getCaption().getValue()); if (uv.getTooltip() != null && uv.getTooltip().length() > 0) menuItem.setToolTipText(uv.getTooltip()); URLMenuItemModel uim = new URLMenuItemModel(); uim.setURLValue(uv); menuItem.setModel(uim); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { URLValue urlValue = ((URLMenuItemModel) ((JMenuItem) e.getSource()).getModel()).getURLValue(); openURL(urlValue); } }); } // Show menu. popupMenu.show((JComponent) iun.peerInstance(), point.x, point.y); }
From source file:org.executequery.gui.editor.QueryEditorPopupMenu.java
private JMenuItem createRollbackMenuItem() { JMenuItem menuItem = MenuItemFactory.createMenuItem(action()); menuItem.setText("Rollback"); menuItem.setActionCommand("rollback"); executeActionButtons().add(menuItem); transactionButtons().add(menuItem);//from w ww .j av a2 s. c om return menuItem; }