List of usage examples for javax.swing JMenuItem JMenuItem
public JMenuItem(Action a)
Action
. From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.links_redundantes.PanelLinkRedundante.java
private void criaInterfaceVisualEscalavel() { miBtnSalvar = new JMenuItem(XHTML_Panel.BTN_SALVAR); painel = new JPanel(); textAreaSourceCode = new G_TextAreaSourceCode(); //frameSilvinha.setJMenuBar(this.criaMenuBar()); textAreaSourceCode.setTipoHTML();//from www .jav a 2 s . c o m textAreaSourceCode.setBorder(criaBorda(XHTML_Panel.COD_FONTE)); //frameSilvinha.setTitle(XHTMLPanel.TIT_LINK_RED); painel.setLayout(new GridLayout(2, 1)); setBackground(frameSilvinha.corDefault); Container contentPane = this; contentPane.setLayout(new GridLayout(1, 1)); painel.add(textAreaSourceCode); JPanel panelBtnTabela = new JPanel(); panelBtnTabela.setLayout(new BorderLayout()); /* * Barra de botes */ btnPanel = new JPanel(); btnPanel.setLayout(null); btn_salvar = new JButton(XHTML_Panel.BTN_SALVAR); btn_salvar.setToolTipText(XHTML_Panel.DICA_SALVAR); btn_salvar.setBounds(10, 0, 150, 25); btnPanel.add(btn_salvar); btn_abrir = new JButton(XHTML_Panel.BTN_ABRIR); btn_abrir.setToolTipText(XHTML_Panel.DICA_ABRIR); btn_abrir.setBounds(165, 0, 150, 25); btnPanel.add(btn_abrir); btn_salvarComo = new JButton(XHTML_Panel.BTN_SALVAR_COMO); btn_salvarComo.setToolTipText(XHTML_Panel.DICA_SALVAR_COMO); btn_salvarComo.setBounds(320, 0, 150, 25); btnPanel.add(btn_salvarComo); btn_cancelar = new JButton(XHTML_Panel.TELA_ANTERIOR); btn_cancelar.setToolTipText(XHTML_Panel.DICA_TELA_ANTERIOR); btn_cancelar.setBounds(480, 0, 150, 25); btnPanel.add(btn_cancelar); btnPanel.setPreferredSize(new Dimension(430, 30)); /* * Barra de correcao */ btnAplicar = new JButton(XHTML_Panel.BTN_APLICAR); btnAplicar.setToolTipText(XHTML_Panel.DICA_BTN_APLICAR); btnAplicar.setEnabled(false); texto = new JTextField(); texto.setBorder(BorderFactory.createLineBorder(Color.BLACK)); JPanel borda = new JPanel(new BorderLayout()); JLabel lbl_texto = new JLabel(XHTML_Panel.ROTULO_TEXTO); lbl_texto.setToolTipText(XHTML_Panel.DICA_ROTULO_TEXTO); borda.add(lbl_texto, BorderLayout.WEST); borda.add(texto, BorderLayout.CENTER); borda.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); borda.setOpaque(false); panelCorretor = new JPanel(new BorderLayout()); panelCorretor.add(borda, BorderLayout.CENTER); panelCorretor.add(btnAplicar, BorderLayout.EAST); //panelCorretor.add(btnPanel,BorderLayout.WEST); panelCorretor.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); panelCorretor.setOpaque(false); /* * Tabela de erros */ tabelaDeErros = new TabelaErros(); scrollPaneTabela = new JScrollPane(); scrollPaneTabela.setViewportView(tabelaDeErros); panelBtnTabela.add(panelCorretor, BorderLayout.NORTH); panelBtnTabela.add(scrollPaneTabela, BorderLayout.CENTER); panelBtnTabela.add(btnPanel, BorderLayout.SOUTH); scrollPaneTabela.setBorder(criaBorda(XHTML_Panel.LISTA_ERROS)); painel.add(panelBtnTabela); btnPanel.setBackground(frameSilvinha.corDefault); if (!original) { reverter = new JButton("Reverter"); reverter.setText(TradPainelRelatorio.REVERTER); reverter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub setVisible(false); TxtBuffer.setContent(TxtBuffer.getContentOriginal()); frameSilvinha.showPainelFerramentaLinksRedundantes(); setVisible(true); } }); //reverter.setActionCommand("Reverter"); reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER); reverter.setBounds(640, 0, 150, 25); btnPanel.add(reverter); } panelBtnTabela.setBackground(frameSilvinha.corDefault); painel.setBackground(frameSilvinha.corDefault); contentPane.setBackground(frameSilvinha.corDefault); scrollPaneTabela.setBackground(frameSilvinha.corDefault); textAreaSourceCode.setBackground(frameSilvinha.corDefault); miBtnSalvar.setEnabled(false); btn_salvar.setEnabled(false); salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(textAreaSourceCode.getTextPane(), btn_salvar, miBtnSalvar, frameSilvinha); String fil[] = { ".html", ".htm" }; salvaAlteracoes.setFiltro(fil); contentPane.add(painel); // pack(); this.setVisible(true); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSwing.CFAsteriskSwingClusterViewEditJInternalFrame.java
public JMenuBar getFrameMenuBar() { if (frameMenuBar == null) { JMenuItem menuItem;/*from w ww . j ava 2s . c o m*/ frameMenuBar = new JMenuBar(); menuFile = new JMenu("File"); actionEdit = new ActionEdit(); menuItem = new JMenuItem(actionEdit); menuFile.add(menuItem); actionSave = new ActionSave(); menuItem = new JMenuItem(actionSave); menuFile.add(menuItem); actionClose = new ActionClose(); menuItem = new JMenuItem(actionClose); menuFile.add(menuItem); frameMenuBar.add(menuFile); } return (frameMenuBar); }
From source file:org.jax.maanova.test.gui.VolcanoPlotPanel.java
/** * Constructor/*w w w . j a v a 2 s .com*/ * @param parent the parent frame * @param maanovaTestResult * the test result to plot * @param initialTestIndex * the initial test index to use * @param selectedIndices * the initially selected indices */ public VolcanoPlotPanel(JFrame parent, MaanovaTestResult maanovaTestResult, int initialTestIndex, int[] selectedIndices) { selectedIndices = SequenceUtilities.uniqueInts(selectedIndices); this.chartConfigurationDialog = new SimpleChartConfigurationDialog(parent); this.chartConfigurationDialog.addOkActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.updateDataPoints(); } }); this.maanovaTestResult = maanovaTestResult; this.saveSelectedPointsMenuItem = new JMenuItem("Save Selected Points to Gene List"); this.saveSelectedPointsMenuItem.setEnabled(selectedIndices != null && selectedIndices.length >= 1); this.saveSelectedPointsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.saveSelectedPoints(); } }); this.displayTestResultsAction = new DisplayTestResultsAction("Show Results Table", maanovaTestResult); this.selectedIndices = selectedIndices; this.setLayout(new BorderLayout()); JPanel chartAndControlPanel = new JPanel(new BorderLayout()); this.add(chartAndControlPanel, BorderLayout.CENTER); this.chartPanel = new MaanovaChartPanel(); this.chartPanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); this.chartPanel.addComponentListener(this.chartComponentListener); this.chartPanel.addAreaSelectionListener(this.areaSelectionListener); this.chartPanel.addMouseListener(this.chartMouseListener); chartAndControlPanel.add(this.chartPanel, BorderLayout.CENTER); this.controlPanel = new JPanel(new FlowLayout()); ItemListener updateDataItemListener = new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.forgetGraphState(); VolcanoPlotPanel.this.updateDataPoints(); } }; this.statisticTypeComboBox = new JComboBox(); for (MaanovaTestStatisticType testStatType : MaanovaTestStatisticType.values()) { this.statisticTypeComboBox.addItem(testStatType); } this.statisticTypeComboBox.addItemListener(updateDataItemListener); this.controlPanel.add(this.statisticTypeComboBox); List<MaanovaTestStatisticSubtype> availableTestSubtypes = new ArrayList<MaanovaTestStatisticSubtype>(); this.statisticSubtypeComboBox = new JComboBox(); MaanovaTestStatistics fStat = this.maanovaTestResult.getStatistics(MaanovaTestStatisticType.F_STAT); for (MaanovaTestStatisticSubtype statSubtype : MaanovaTestStatisticSubtype.values()) { if (fStat.hasTestStatistic(statSubtype)) { availableTestSubtypes.add(statSubtype); if (statSubtype != MaanovaTestStatisticSubtype.F_OBSERVED) { this.statisticSubtypeComboBox.addItem(statSubtype); } } } this.statisticSubtypeComboBox.addItemListener(updateDataItemListener); this.controlPanel.add(this.statisticSubtypeComboBox); int testStatCount = availableTestSubtypes.size() * MaanovaTestStatisticType.values().length; this.availableTestStatistics = new TestStatisticItem[testStatCount]; for (int i = 0; i < MaanovaTestStatisticType.values().length; i++) { for (int j = 0; j < availableTestSubtypes.size(); j++) { int flatIndex = i * availableTestSubtypes.size() + j; this.availableTestStatistics[flatIndex] = new TestStatisticItem( MaanovaTestStatisticType.values()[i], availableTestSubtypes.get(j)); } } int testCount = fStat.getContrastCount(); if (testCount == 1) { this.testNumberComboBox = null; } else { this.testNumberComboBox = new JComboBox(); for (int i = 1; i <= testCount; i++) { this.testNumberComboBox.addItem("Test Number " + i); } this.testNumberComboBox.setSelectedIndex(initialTestIndex); this.testNumberComboBox.addItemListener(updateDataItemListener); this.controlPanel.add(this.testNumberComboBox); } chartAndControlPanel.add(this.controlPanel, BorderLayout.NORTH); JMenuBar menu = this.createMenu(); this.add(menu, BorderLayout.NORTH); this.forgetGraphState(); this.updateDataPoints(); this.chartPanel.addMouseMotionListener(this.myMouseMotionListener); this.chartPanel.setLayout(null); this.toolTip = new JToolTip(); }
From source file:com.mirth.connect.client.ui.components.MirthTable.java
private JPopupMenu getColumnMenu() { JPopupMenu columnMenu = new JPopupMenu(); DefaultTableModel model = (DefaultTableModel) getModel(); for (int i = 0; i < model.getColumnCount(); i++) { final String columnName = model.getColumnName(i); // Get the column object by name. Using an index may not return the column object if the column is hidden TableColumnExt column = getColumnExt(columnName); // Create the menu item final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(columnName); // Show or hide the checkbox menuItem.setSelected(column.isVisible()); menuItem.addActionListener(new ActionListener() { @Override//from w w w. j a v a 2s.c om public void actionPerformed(ActionEvent evt) { TableColumnExt column = getColumnExt(menuItem.getText()); // Determine whether to show or hide the selected column boolean enable = !column.isVisible(); // Do not hide a column if it is the last remaining visible column if (enable || getColumnCount() > 1) { column.setVisible(enable); saveColumnOrder(); } } }); columnMenu.add(menuItem); } columnMenu.addSeparator(); JMenuItem menuItem = new JMenuItem("Restore Default"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { restoreDefaultColumnPreferences(); } }); columnMenu.add(menuItem); return columnMenu; }
From source file:edu.harvard.mcz.imagecapture.DeterminationFrame.java
/** * This method initializes jTable /*from www. java 2 s .c o m*/ * * @return javax.swing.JTable */ private JTable getJTable() { if (jTableDeterminations == null) { jTableDeterminations = new JTable(); DeterminationTableModel model = new DeterminationTableModel(); jTableDeterminations.setModel(model); if (determinations != null) { jTableDeterminations.setModel(determinations); } FilteringAgentJComboBox field = new FilteringAgentJComboBox(); jTableDeterminations.getColumnModel().getColumn(DeterminationTableModel.ROW_IDENTIFIEDBY) .setCellEditor(new ComboBoxCellEditor(field)); setTableColumnEditors(); jTableDeterminations.setRowHeight(jTableDeterminations.getRowHeight() + 4); jTableDeterminations.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnDetsRow = ((JTable) e.getComponent()).getSelectedRow(); jPopupDets.show(e.getComponent(), e.getX(), e.getY()); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnDetsRow = ((JTable) e.getComponent()).getSelectedRow(); jPopupDets.show(e.getComponent(), e.getX(), e.getY()); } } }); jPopupDets = new JPopupMenu(); JMenuItem mntmDeleteRow = new JMenuItem("Delete Row"); mntmDeleteRow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { log.debug(clickedOnDetsRow); if (clickedOnDetsRow >= 0) { int ok = JOptionPane.showConfirmDialog(thisFrame, "Delete the selected determination?", "Delete Determination", JOptionPane.OK_CANCEL_OPTION); if (ok == JOptionPane.OK_OPTION) { log.debug("deleting determination row " + clickedOnDetsRow); ((DeterminationTableModel) jTableDeterminations.getModel()) .deleteRow(clickedOnDetsRow); } else { log.debug("determination row delete canceled by user."); } } else { JOptionPane.showMessageDialog(thisFrame, "Unable to select row to delete."); } } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(thisFrame, "Failed to delete a determination row. " + ex.getMessage()); } } }); jPopupDets.add(mntmDeleteRow); } return jTableDeterminations; }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
private JMenuItem createMenuItem(String text) { JMenuItem menuItem = new JMenuItem(text); menuItem.addActionListener(this); return menuItem; }
From source file:edu.clemson.cs.nestbed.client.gui.NetworkMonitorFrame.java
private final JMenu buildNetworkMenu() { final JMenu menu = new JMenu("Network"); final JMenuItem install = new JMenuItem("Install Programs"); final JMenuItem vizMenu = new JMenuItem("Visualizations"); install.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new Thread() { public void run() { try { install.setEnabled(false); progDeployMgr.deployConfiguration(config.getID()); } catch (Exception ex) { log.error("Exception occured while installing " + "programs.", ex); ClientUtils.displayErrorMessage(NetworkMonitorFrame.this, ex); } finally { install.setEnabled(true); }//from w ww .j a va2 s.c o m } }.start(); } }); menu.add(install); menu.add(new JSeparator()); vizMenu.addActionListener(new VisualizationMenuListener()); menu.add(vizMenu); return menu; }
From source file:gdt.jgui.entity.bonddetail.JBondDetailPanel.java
/** * Get the context menu./* www.j av a2s . c om*/ * @return the context menu. */ @Override public JMenu getContextMenu() { menu1 = new JMenu("Context"); menu1.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { // System.out.println("JBondDetailPanel:getConextMenu:BEGIN"); menu1.removeAll(); JMenuItem selectItem = new JMenuItem("Select all"); selectItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JItemPanel[] ipa = getItems(); if (ipa != null) { for (JItemPanel ip : ipa) ip.setChecked(true); } } }); menu1.add(selectItem); JMenuItem unselectItem = new JMenuItem("Unselect all"); unselectItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JItemPanel[] ipa = getItems(); if (ipa != null) { for (JItemPanel ip : ipa) ip.setChecked(false); } } }); menu1.addSeparator(); JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (requesterResponseLocator$ != null) { try { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); JConsoleHandler.execute(console, responseLocator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } else console.back(); } }); menu1.add(doneItem); menu1.addSeparator(); addItem = new JMenuItem("Add"); addItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Entigrator entigrator = console.getEntigrator(entihome$); JContext adp = (JContext) ExtensionHandler.loadHandlerInstance(entigrator, BondDetailHandler.EXTENSION_KEY, "gdt.jgui.entity.bonddetail.JAddDetailPanel"); String adpLocator$ = adp.getLocator(); adpLocator$ = Locator.append(adpLocator$, Entigrator.ENTIHOME, entihome$); adpLocator$ = Locator.append(adpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, adpLocator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu1.add(addItem); if (hasToPaste()) { JMenuItem pasteItem = new JMenuItem("Paste"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { paste(); } }); menu1.add(pasteItem); } if (hasSelectedItems()) { JMenuItem deleteItem = new JMenuItem("Delete"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { delete(); JBondDetailPanel bdp = new JBondDetailPanel(); String bdpLocator$ = bdp.getLocator(); bdpLocator$ = Locator.append(bdpLocator$, Entigrator.ENTIHOME, entihome$); bdpLocator$ = Locator.append(bdpLocator$, EntityHandler.ENTITY_KEY, entityKey$); bdpLocator$ = Locator.append(bdpLocator$, JBondsPanel.BOND_KEY, bondKey$); JConsoleHandler.execute(console, bdpLocator$); } } }); menu1.add(deleteItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu1; }
From source file:edu.clemson.cs.nestbed.client.gui.TestbedManagerFrame.java
private final JMenu buildProjectMenu() { final JMenu menu = new JMenu("Project"); final JMenuItem addProject = new JMenuItem("Add"); final JMenuItem deleteProject = new JMenuItem("Delete"); addProject.addActionListener(new AddProjectActionListener()); menu.add(addProject);//from w w w . j ava 2s . c o m deleteProject.addActionListener(new DeleteProjectActionListener()); menu.add(deleteProject); menu.addMenuListener(new ProjectMenuListener(addProject, deleteProject)); return menu; }
From source file:edu.clemson.cs.nestbed.client.gui.MoteDetailFrame.java
private JMenu buildFileMenu() { JMenu menu = new JMenu("File"); JMenuItem close = new JMenuItem("Close"); close.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MoteDetailFrame.this.setVisible(false); }/*from ww w . j a v a2s. c om*/ }); menu.add(close); return menu; }