List of usage examples for javax.swing JPopupMenu JPopupMenu
public JPopupMenu()
JPopupMenu
without an "invoker". From source file:net.rptools.maptool.client.ui.MapToolFrame.java
private AssetPanel createAssetPanel() { final AssetPanel panel = new AssetPanel("mainAssetPanel"); panel.addImagePanelMouseListener(new MouseAdapter() { @Override//w ww . j a v a2 s . co m public void mouseReleased(MouseEvent e) { // TODO use for real popup logic // if (SwingUtilities.isLeftMouseButton(e)) { // if (e.getClickCount() == 2) { // // List<Object> idList = panel.getSelectedIds(); // if (idList == null || idList.size() == 0) { // return; // } // // final int index = (Integer) idList.get(0); // createZone(panel.getAsset(index)); // } // } if (SwingUtilities.isRightMouseButton(e) && MapTool.getPlayer().isGM()) { List<Object> idList = panel.getSelectedIds(); if (idList == null || idList.size() == 0) { return; } final int index = (Integer) idList.get(0); JPopupMenu menu = new JPopupMenu(); menu.add(new JMenuItem(new AbstractAction() { { putValue(NAME, I18N.getText("action.newMap")); } public void actionPerformed(ActionEvent e) { createZone(panel.getAsset(index)); } })); panel.showImagePanelPopup(menu, e.getX(), e.getY()); } } private void createZone(Asset asset) { Zone zone = ZoneFactory.createZone(); zone.setName(asset.getName()); BufferedImage image = ImageManager.getImageAndWait(asset.getId()); if (image.getWidth() < 200 || image.getHeight() < 200) { zone.setBackgroundPaint(new DrawableTexturePaint(asset)); } else { zone.setMapAsset(asset.getId()); zone.setBackgroundPaint(new DrawableColorPaint(Color.black)); } MapPropertiesDialog newMapDialog = new MapPropertiesDialog(MapTool.getFrame()); newMapDialog.setZone(zone); newMapDialog.setVisible(true); if (newMapDialog.getStatus() == MapPropertiesDialog.Status.OK) { MapTool.addZone(zone); } } }); return panel; }
From source file:com.mirth.connect.client.ui.Frame.java
/** * Creates the status task pane./*from ww w. j a va 2 s. co m*/ */ private void createDashboardPane() { // Create Status Tasks Pane dashboardTasks = new JXTaskPane(); dashboardPopupMenu = new JPopupMenu(); dashboardTasks.setTitle("Dashboard Tasks"); dashboardTasks.setName(TaskConstants.DASHBOARD_KEY); dashboardTasks.setFocusable(false); addTask(TaskConstants.DASHBOARD_REFRESH, "Refresh", "Refresh the list of statuses.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/arrow_refresh.png")), dashboardTasks, dashboardPopupMenu); addTask(TaskConstants.DASHBOARD_SEND_MESSAGE, "Send Message", "Send messages to the currently selected channel.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/email_go.png")), dashboardTasks, dashboardPopupMenu); addTask(TaskConstants.DASHBOARD_SHOW_MESSAGES, "View Messages", "Show the messages for the currently selected channel.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/page_white_stack.png")), dashboardTasks, dashboardPopupMenu); addTask(TaskConstants.DASHBOARD_REMOVE_ALL_MESSAGES, "Remove All Messages", "Remove all Messages in this channel.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/email_delete.png")), dashboardTasks, dashboardPopupMenu); addTask(TaskConstants.DASHBOARD_CLEAR_STATS, "Clear Statistics", "Reset the statistics for this channel.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/chart_bar_delete.png")), dashboardTasks, dashboardPopupMenu); addTask(TaskConstants.DASHBOARD_START, "Start", "Start the currently selected channel.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/control_play_blue.png")), dashboardTasks, dashboardPopupMenu); addTask(TaskConstants.DASHBOARD_PAUSE, "Pause", "Pause the currently selected channel.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/control_pause_blue.png")), dashboardTasks, dashboardPopupMenu); addTask(TaskConstants.DASHBOARD_STOP, "Stop", "Stop the currently selected channel.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/control_stop_blue.png")), dashboardTasks, dashboardPopupMenu); addTask(TaskConstants.DASHBOARD_HALT, "Halt", "Halt the currently selected channel.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/stop.png")), dashboardTasks, dashboardPopupMenu); addTask(TaskConstants.DASHBOARD_UNDEPLOY, "Undeploy Channel", "Undeploys the currently selected channel.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/arrow_undo.png")), dashboardTasks, dashboardPopupMenu); addTask(TaskConstants.DASHBOARD_START_CONNECTOR, "Start", "Start the currently selected connector.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/control_play_blue.png")), dashboardTasks, dashboardPopupMenu); addTask(TaskConstants.DASHBOARD_STOP_CONNECTOR, "Stop", "Stop the currently selected connector.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/control_stop_blue.png")), dashboardTasks, dashboardPopupMenu); setNonFocusable(dashboardTasks); taskPaneContainer.add(dashboardTasks); }
From source file:org.fhaes.jsea.JSEAFrame.java
/** * Setup the GUI components//from w w w . jav a 2 s .c o m */ private void setupGui() { setTitle("jSEA - Superposed Epoch Analysis"); getContentPane().setLayout(new MigLayout("", "[1200px,grow,fill]", "[][600px,grow,fill]")); initActions(); setupMenu(); setupToolbar(); this.setIconImage(Builder.getApplicationIcon()); { JSplitPane splitPane = new JSplitPane(); splitPane.setOneTouchExpandable(true); getContentPane().add(splitPane, "cell 0 1,alignx left,aligny top"); splitPane.setLeftComponent(contentPanel); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPanel.setLayout(new MigLayout("", "[grow,fill]", "[78.00][][][grow][]")); { JPanel panel = new JPanel(); panel.setBorder( new TitledBorder(null, "Input Files", TitledBorder.LEADING, TitledBorder.TOP, null, null)); contentPanel.add(panel, "cell 0 0,grow"); panel.setLayout(new MigLayout("", "[][][grow][]", "[][]")); { JLabel lblContinuousTimeSeries = new JLabel("Continuous time series file:"); panel.add(lblContinuousTimeSeries, "cell 0 0,alignx trailing"); } { HelpTipButton label = new HelpTipButton( "Continuous time series data files should be two column comma seperated (CSV) text files. Column one should contains the years (in sequence), and column two should contain the data values. If there are header lines or comments in the file, these lines should beginning with a *"); panel.add(label, "cell 1 0,alignx trailing"); } { txtTimeSeriesFile = new JTextField(); txtwrapper = new TextComponentWrapper(txtTimeSeriesFile, PrefKey.JSEA_CONTINUOUS_TIME_SERIES_FILE, ""); txtTimeSeriesFile.setEditable(true); panel.add(txtTimeSeriesFile, "cell 2 0,growx"); txtTimeSeriesFile.setColumns(10); } { btnTimeSeriesFile = new JButton(); btnTimeSeriesFile.setIcon(Builder.getImageIcon("fileopen16.png")); btnTimeSeriesFile.setActionCommand("TimeSeriesFileBrowse"); btnTimeSeriesFile.addActionListener(this); btnTimeSeriesFile.setPreferredSize(new Dimension(25, 25)); btnTimeSeriesFile.setMaximumSize(new Dimension(25, 25)); btnTimeSeriesFile.putClientProperty("JButton.buttonType", "segmentedTextured"); btnTimeSeriesFile.putClientProperty("JButton.segmentPosition", "middle"); panel.add(btnTimeSeriesFile, "cell 3 0"); } { JLabel lblEventListFile = new JLabel("Event list file:"); panel.add(lblEventListFile, "cell 0 1,alignx trailing"); } { HelpTipButton helpTipButton = new HelpTipButton( "Event data files should be a text file with a single column of integer year values. If there are any header or comment lines, these should begin with a *"); panel.add(helpTipButton, "cell 1 1,alignx trailing"); } { txtEventListFile = new JTextField(); new TextComponentWrapper(txtEventListFile, PrefKey.JSEA_EVENT_LIST_FILE, ""); txtEventListFile.setEditable(false); panel.add(txtEventListFile, "cell 2 1,growx"); txtEventListFile.setColumns(10); } { btnEventListFile = new JButton(); btnEventListFile.setIcon(Builder.getImageIcon("fileopen16.png")); btnEventListFile.setActionCommand("EventListFileBrowse"); btnEventListFile.addActionListener(this); btnEventListFile.setPreferredSize(new Dimension(25, 25)); btnEventListFile.setMaximumSize(new Dimension(25, 25)); btnEventListFile.putClientProperty("JButton.buttonType", "segmentedTextured"); btnEventListFile.putClientProperty("JButton.segmentPosition", "middle"); panel.add(btnEventListFile, "cell 3 1"); } } { JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(null, "Window, Simulation and Statistics", TitledBorder.LEADING, TitledBorder.TOP, null, null)); contentPanel.add(panel, "cell 0 1,grow"); panel.setLayout(new MigLayout("", "[right][][fill][10px:10px:10px][right][][90.00,grow,fill]", "[grow][][][]")); { JLabel lblYears = new JLabel("Years to analyse:"); panel.add(lblYears, "cell 0 0"); } { HelpTipButton helpTipButton = new HelpTipButton( "Specify which years from the dataset to analyse."); panel.add(helpTipButton, "cell 1 0"); } { JPanel panel_1 = new JPanel(); panel.add(panel_1, "cell 2 0 5 1,grow"); panel_1.setLayout(new MigLayout("fill, insets 0", "[80px:80px][][80px:80px,fill][grow]", "[]")); { spnFirstYear = new JSpinner(); spnFirstYear.setEnabled(false); panel_1.add(spnFirstYear, "cell 0 0,growx"); spnFirstYear.setModel(new SpinnerNumberModel(new Integer(0), null, null, new Integer(1))); spnFirstYear.setEditor(new JSpinner.NumberEditor(spnFirstYear, "#")); new SpinnerWrapper(spnFirstYear, PrefKey.JSEA_FIRST_YEAR, 0); } { JLabel lblTo = new JLabel("-"); panel_1.add(lblTo, "cell 1 0"); } { spnLastYear = new JSpinner(); spnLastYear.setEnabled(false); panel_1.add(spnLastYear, "cell 2 0"); spnLastYear.setModel(new SpinnerNumberModel(new Integer(2020), null, null, new Integer(1))); spnLastYear.setEditor(new JSpinner.NumberEditor(spnLastYear, "#")); new SpinnerWrapper(spnLastYear, PrefKey.JSEA_LAST_YEAR, 2020); } { chkAllYears = new JCheckBox("all years in series"); chkAllYears.setSelected(true); chkAllYears.setActionCommand("AllYearsCheckbox"); chkAllYears.addActionListener(this); panel_1.add(chkAllYears, "cell 3 0"); } } { JLabel lblLagsPriorTo = new JLabel("Lags prior to event:"); panel.add(lblLagsPriorTo, "cell 0 1"); } { HelpTipButton helpTipButton = new HelpTipButton(""); panel.add(helpTipButton, "cell 1 1"); } { spnLagsPrior = new JSpinner(); new SpinnerWrapper(spnLagsPrior, PrefKey.JSEA_LAGS_PRIOR_TO_EVENT, 6); panel.add(spnLagsPrior, "cell 2 1,growx"); // spnLagsPrior.setModel(new SpinnerNumberModel(6, 1, 100, 1)); spnLagsPrior.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { segmentationPanel.table.tableModel.clearSegments(); validateForm(); } }); } { JLabel lblSimulationsToRun = new JLabel("Simulations:"); panel.add(lblSimulationsToRun, "cell 4 1"); } { HelpTipButton helpTipButton = new HelpTipButton( "Number of simulations to run. Increasing the number of simulations increases the analysis time."); panel.add(helpTipButton, "cell 5 1"); } { spnSimulationsToRun = new JSpinner(); new SpinnerWrapper(spnSimulationsToRun, PrefKey.JSEA_SIMULATION_COUNT, 1000); panel.add(spnSimulationsToRun, "cell 6 1"); spnSimulationsToRun.setModel(new SpinnerNumberModel(1000, 1, 10096, 1)); } { JLabel lblLagsFollowingThe = new JLabel("Lags following the event:"); panel.add(lblLagsFollowingThe, "cell 0 2"); } { HelpTipButton helpTipButton = new HelpTipButton(""); panel.add(helpTipButton, "cell 1 2"); } { spnLagsAfter = new JSpinner(); new SpinnerWrapper(spnLagsAfter, PrefKey.JSEA_LAGS_AFTER_EVENT, 4); panel.add(spnLagsAfter, "cell 2 2,growx"); spnLagsAfter.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { segmentationPanel.table.tableModel.clearSegments(); validateForm(); } }); } { JLabel lblSeedNumber = new JLabel("Seed number:"); panel.add(lblSeedNumber, "cell 4 2"); } { HelpTipButton helpTipButton = new HelpTipButton( "The analysis requires a pseudo-random component which is seeded with the seed number (a large integer value). Running analyses with the same seed number enables produces the same results. You can leave the seed as the default number unless you specifically want to generate results from a different randomised pool."); panel.add(helpTipButton, "cell 5 2"); } { spnSeedNumber = new JSpinner(); new SpinnerWrapper(spnSeedNumber, PrefKey.JSEA_SEED_NUMBER, 30188); panel.add(spnSeedNumber, "cell 6 2"); spnSeedNumber.setModel(new SpinnerNumberModel(30188, 10000, 1000000, 1)); } { JLabel lblIncludeIncompleteWindow = new JLabel("Include incomplete epoch:"); panel.add(lblIncludeIncompleteWindow, "cell 0 3"); } { HelpTipButton helpTipButton = new HelpTipButton(""); panel.add(helpTipButton, "cell 1 3"); } { chkIncludeIncompleteWindow = new JCheckBox(""); new CheckBoxWrapper(chkIncludeIncompleteWindow, PrefKey.JSEA_INCLUDE_INCOMPLETE_WINDOW, false); panel.add(chkIncludeIncompleteWindow, "cell 2 3"); } { JLabel lblPvalue = new JLabel("p-value:"); panel.add(lblPvalue, "cell 4 3"); } { HelpTipButton helpTipButton = new HelpTipButton( "The cutoff value to use for statistical significance"); panel.add(helpTipButton, "cell 5 3,alignx trailing"); } { cbxPValue = new JComboBox(); panel.add(cbxPValue, "cell 6 3"); cbxPValue.setModel(new DefaultComboBoxModel(new Double[] { 0.05, 0.01, 0.001 })); } } { JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(null, "Chart Options", TitledBorder.LEADING, TitledBorder.TOP, null, null)); contentPanel.add(panel, "cell 0 2,grow"); panel.setLayout(new MigLayout("", "[right][][grow]", "[][]")); { JLabel lblTitleOfChart = new JLabel("Title of chart:"); panel.add(lblTitleOfChart, "cell 0 0,alignx trailing"); } { HelpTipButton helpTipButton = new HelpTipButton( "Title to use on the chart. The placeholder {segment} is replaced with the years of the segment being plotted."); panel.add(helpTipButton, "cell 1 0,alignx trailing"); } { txtChartTitle = new JTextField(); txtChartTitle.setToolTipText("<html>Title to be displayed on the<br/>" + "chart output"); new TextComponentWrapper(txtChartTitle, PrefKey.JSEA_CHART_TITLE, "Chart title {segment}"); panel.add(txtChartTitle, "cell 2 0,growx,aligny top"); txtChartTitle.setColumns(10); } { JLabel lblYaxisLabel = new JLabel("Continuous series (y-axis) label"); panel.add(lblYaxisLabel, "cell 0 1,alignx trailing"); } { txtYAxisLabel = new JTextField(); txtYAxisLabel .setToolTipText("<html>Label to be displayed on the<br/> " + "continuous series axis"); new TextComponentWrapper(txtYAxisLabel, PrefKey.JSEA_YAXIS_LABEL, "Y Axis"); panel.add(txtYAxisLabel, "cell 2 1,growx"); txtYAxisLabel.setColumns(10); } } { // Segmentation implementation used from FHSampleSize segmentationPanel = new SegmentationPanel(); segmentationPanel.chkSegmentation.setText("Process subset or segments of events?"); segmentationPanel.chkSegmentation.setActionCommand("SegmentationMode"); segmentationPanel.chkSegmentation.addActionListener(this); contentPanel.add(segmentationPanel, "cell 0 3,grow"); } { tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM); splitPane.setRightComponent(tabbedPane); { summaryPanel = new JPanel(); tabbedPane.addTab("Summary ", Builder.getImageIcon("info.png"), summaryPanel, null); summaryPanel.setLayout(new BorderLayout(0, 0)); { scrollPane = new JScrollPane(); summaryPanel.add(scrollPane); { txtSummary = new JTextArea(); txtSummary.setEditable(false); scrollPane.setViewportView(txtSummary); JMenuItem mntmCopy = new JMenuItem(actionCopy); JPopupMenu popup = new JPopupMenu(); addPopup(scrollPane, popup); popup.add(mntmCopy); } } } { dataPanel = new JPanel(); tabbedPane.addTab("Data ", Builder.getImageIcon("table.png"), dataPanel, null); dataPanel.setLayout(new MigLayout("", "[grow,fill]", "[grow]")); { JSplitPane splitPaneDataTables = new JSplitPane(); splitPaneDataTables.setResizeWeight(0.5); splitPaneDataTables.setOneTouchExpandable(true); splitPaneDataTables.setOrientation(JSplitPane.VERTICAL_SPLIT); dataPanel.add(splitPaneDataTables, "cell 0 0,grow"); { JPanel panel = new JPanel(); splitPaneDataTables.setLeftComponent(panel); panel.setBorder(new TitledBorder(null, "Actual key events", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel.setLayout(new MigLayout("", "[227.00px,grow,fill]", "[68.00px,grow,fill]")); { JScrollPane scrollPane = new JScrollPane(); panel.add(scrollPane, "cell 0 0,grow"); { tblActual = new JXTable(); adapterActualTable = new JTableSpreadsheetByRowAdapter(tblActual); scrollPane.setViewportView(tblActual); tblActual.setSortable(false); JMenuItem mntmCopy = new JMenuItem(actionCopy); JPopupMenu popup = new JPopupMenu(); addPopup(tblActual, popup); popup.add(mntmCopy); } } } { JPanel panel = new JPanel(); splitPaneDataTables.setRightComponent(panel); panel.setBorder(new TitledBorder(null, "Simulation results", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel.setLayout(new MigLayout("", "[grow,fill]", "[grow,fill]")); { JScrollPane scrollPane = new JScrollPane(); panel.add(scrollPane, "cell 0 0,grow"); { tblSimulation = new JXTable(); adapterSimulationTable = new JTableSpreadsheetByRowAdapter(tblSimulation); scrollPane.setViewportView(tblSimulation); tblSimulation.setSortable(false); JMenuItem mntmCopy = new JMenuItem(actionCopy); JPopupMenu popup = new JPopupMenu(); addPopup(tblSimulation, popup); popup.add(mntmCopy); } } } splitPaneDataTables.setDividerLocation(0.5f); } } { chartPanel = new JPanel(); tabbedPane.addTab("Chart ", Builder.getImageIcon("barchart.png"), chartPanel, null); chartPanel.setLayout(new MigLayout("", "[][grow]", "[][grow]")); { segmentComboBox = new JComboBox(); segmentComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { if (segmentComboBox.getItemCount() > 0) { barChart = new JSEABarChart( jsea.getChartList().get(segmentComboBox.getSelectedIndex())); barChart.setMaximumDrawHeight(MAX_DRAW_HEIGHT); barChart.setMaximumDrawWidth(MAX_DRAW_WIDTH); chartPanel.removeAll(); chartPanel.add(plotSegmentLabel, "cell 0 0,alignx center,aligny center"); chartPanel.add(segmentComboBox, "cell 1 0,growx,aligny center"); chartPanel.add(barChart, "cell 0 1 2 1,grow"); chartPanel.revalidate(); chartPanel.repaint(); } } }); { plotSegmentLabel = new JLabel("Plot Segment: "); chartPanel.add(plotSegmentLabel, "cell 0 0,alignx center,aligny center"); } chartPanel.add(segmentComboBox, "cell 1 0,growx,aligny center"); } } } } pack(); validateForm(); setAnalysisAvailable(false); setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH); }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
/** * Shows Parent Form's Context Menu.//from ww w . jav a 2 s . c o m * @param e the mouse event */ protected void showContextMenu(MouseEvent e) { if (e.isPopupTrigger() && mvParent != null && mvParent.isTopLevel() && isEditing) { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(UIRegistry.getResourceString("CONFIG_CARRY_FORWARD_MENU")); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { configureCarryForward(); } }); popup.add(menuItem); JCheckBoxMenuItem chkMI = new JCheckBoxMenuItem( UIRegistry.getResourceString("CARRY_FORWARD_CHECKED_MENU")); chkMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { toggleCarryForward(); } }); chkMI.setSelected(isCarryForwardConfgured() && isDoCarryForward()); chkMI.setEnabled(isCarryForwardConfgured()); popup.add(chkMI); popup.addSeparator(); chkMI = new JCheckBoxMenuItem(UIRegistry.getAction(AUTO_NUM)); /*chkMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { toggleAutoNumberOnOffState(); } });*/ chkMI.setSelected(isAutoNumberOn); popup.add(chkMI); popup.show(e.getComponent(), e.getX(), e.getY()); } }
From source file:com.mirth.connect.client.ui.Frame.java
/** * Creates the event task pane.//from ww w .java2 s . c om */ private void createEventPane() { // Create Event Tasks Pane eventTasks = new JXTaskPane(); eventPopupMenu = new JPopupMenu(); eventTasks.setTitle("Event Tasks"); eventTasks.setName(TaskConstants.EVENT_KEY); eventTasks.setFocusable(false); addTask(TaskConstants.EVENT_REFRESH, "Refresh", "Refresh the list of events with the given filter.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/arrow_refresh.png")), eventTasks, eventPopupMenu); addTask(TaskConstants.EVENT_EXPORT_ALL, "Export All Events", "Export all events to a file on the server.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/report_disk.png")), eventTasks, eventPopupMenu); addTask(TaskConstants.EVENT_REMOVE_ALL, "Remove All Events", "Remove all events and optionally export them to a file on the server.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/table_delete.png")), eventTasks, eventPopupMenu); setNonFocusable(eventTasks); taskPaneContainer.add(eventTasks); }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * @param actionTree//from w w w . j a va 2 s. com */ private void registerPrintContextMenu(final JTree actionTree) { actionTree.addMouseListener(new MouseAdapter() { private void displayMenu(MouseEvent e) { if (e.isPopupTrigger()) { JPopupMenu menu = new JPopupMenu(); JMenuItem printMenu = new JMenuItem(UIRegistry.getResourceString("Print")); menu.add(printMenu); menu.show(e.getComponent(), e.getX(), e.getY()); printMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { print(actionTree); } }); } } @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); displayMenu(e); } @Override public void mousePressed(MouseEvent e) { super.mousePressed(e); displayMenu(e); } @Override public void mouseReleased(MouseEvent e) { super.mouseReleased(e); displayMenu(e); } }); }
From source file:com.mirth.connect.client.ui.Frame.java
/** * Creates the message task pane./*w w w .jav a2 s . c o m*/ */ private void createMessagePane() { // Create Message Tasks Pane messageTasks = new JXTaskPane(); messagePopupMenu = new JPopupMenu(); messageTasks.setTitle("Message Tasks"); messageTasks.setName(TaskConstants.MESSAGE_KEY); messageTasks.setFocusable(false); addTask(TaskConstants.MESSAGE_REFRESH, "Refresh", "Refresh the list of messages with the current search criteria.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/arrow_refresh.png")), messageTasks, messagePopupMenu); addTask(TaskConstants.MESSAGE_SEND, "Send Message", "Send a message to the channel.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/email_go.png")), messageTasks, messagePopupMenu); addTask(TaskConstants.MESSAGE_IMPORT, "Import Messages", "Import messages from a file.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/report_go.png")), messageTasks, messagePopupMenu); addTask(TaskConstants.MESSAGE_EXPORT, "Export Results", "Export all messages in the current search.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/report_disk.png")), messageTasks, messagePopupMenu); addTask(TaskConstants.MESSAGE_REMOVE_ALL, "Remove All Messages", "Remove all messages in this channel.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/email_delete.png")), messageTasks, messagePopupMenu); addTask(TaskConstants.MESSAGE_REMOVE_FILTERED, "Remove Results", "Remove all messages in the current search.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/email_delete.png")), messageTasks, messagePopupMenu); addTask(TaskConstants.MESSAGE_REMOVE, "Remove Message", "Remove the selected Message.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/delete.png")), messageTasks, messagePopupMenu); addTask(TaskConstants.MESSAGE_REPROCESS_FILTERED, "Reprocess Results", "Reprocess all messages in the current search.", "", new ImageIcon( com.mirth.connect.client.ui.Frame.class.getResource("images/arrow_rotate_clockwise.png")), messageTasks, messagePopupMenu); addTask(TaskConstants.MESSAGE_REPROCESS, "Reprocess Message", "Reprocess the selected message.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/arrow_redo.png")), messageTasks, messagePopupMenu); addTask(TaskConstants.MESSAGE_VIEW_IMAGE, "View Attachment", "View Attachment", "View the attachment for the selected message.", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/attach.png")), messageTasks, messagePopupMenu); addTask(TaskConstants.MESSAGE_EXPORT_ATTACHMENT, "Export Attachment", "Export Attachment", "Export the selected attachment to a file.", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/report_disk.png")), messageTasks, messagePopupMenu); setNonFocusable(messageTasks); taskPaneContainer.add(messageTasks); }
From source file:jp.massbank.spectrumsearch.SearchPage.java
/** * ?//from www .j a v a 2s . c o m * @param e */ private void recListPopup(MouseEvent e) { JTable tbl = null; JScrollPane pane = null; try { tbl = (JTable) e.getSource(); } catch (ClassCastException cce) { pane = (JScrollPane) e.getSource(); if (pane.equals(queryDbPane)) { tbl = queryDbTable; } else if (pane.equals(resultPane)) { tbl = resultTable; } if (pane.equals(queryFilePane)) { tbl = queryFileTable; } } int rowCnt = tbl.getSelectedRows().length; JMenuItem item1 = new JMenuItem("Show Record"); item1.addActionListener(new PopupShowRecordListener(tbl)); JMenuItem item2 = new JMenuItem("Multiple Display"); item2.addActionListener(new PopupMultipleDisplayListener(tbl)); // ? if (tbl.equals(queryFileTable)) { item1.setEnabled(false); item2.setEnabled(false); } else if (rowCnt == 0) { item1.setEnabled(false); item2.setEnabled(false); } else if (rowCnt == 1) { item1.setEnabled(true); item2.setEnabled(false); } else if (rowCnt > 1) { item1.setEnabled(false); item2.setEnabled(true); } // ? JPopupMenu popup = new JPopupMenu(); popup.add(item1); if (tbl.equals(resultTable)) { popup.add(item2); } popup.show(e.getComponent(), e.getX(), e.getY()); }
From source file:com.mirth.connect.client.ui.Frame.java
/** * Creates the users task pane.//from www. j a va 2 s . c om */ private void createUserPane() { // Create User Tasks Pane userTasks = new JXTaskPane(); userPopupMenu = new JPopupMenu(); userTasks.setTitle("User Tasks"); userTasks.setName(TaskConstants.USER_KEY); userTasks.setFocusable(false); addTask(TaskConstants.USER_REFRESH, "Refresh", "Refresh the list of users.", "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/arrow_refresh.png")), userTasks, userPopupMenu); addTask(TaskConstants.USER_NEW, "New User", "Create a new user.", "N", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/user_add.png")), userTasks, userPopupMenu); addTask(TaskConstants.USER_EDIT, "Edit User", "Edit the currently selected user.", "I", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/user_edit.png")), userTasks, userPopupMenu); addTask(TaskConstants.USER_DELETE, "Delete User", "Delete the currently selected user.", "L", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/user_delete.png")), userTasks, userPopupMenu); setNonFocusable(userTasks); taskPaneContainer.add(userTasks); }
From source file:com.pironet.tda.TDA.java
public void createPopupMenu() { //Create the popup menu. JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Diff Selection"); menuItem.addActionListener(this); popup.add(menuItem);/* w w w. ja v a 2 s. c om*/ menuItem = new JMenuItem("Find long running threads..."); menuItem.addActionListener(this); popup.add(menuItem); showDumpMenuItem = new JMenuItem("Show selected Dump in logfile"); showDumpMenuItem.addActionListener(this); showDumpMenuItem.setEnabled(false); if (!runningAsJConsolePlugin && !runningAsVisualVMPlugin) { popup.addSeparator(); menuItem = new JMenuItem("Parse loggc-logfile..."); menuItem.addActionListener(this); if (!PrefManager.get().getForceLoggcLoading()) { menuItem.setEnabled(!isFoundClassHistogram); } popup.add(menuItem); menuItem = new JMenuItem("Close logfile..."); menuItem.addActionListener(this); popup.add(menuItem); popup.addSeparator(); popup.add(showDumpMenuItem); } else { popup.addSeparator(); if (!runningAsVisualVMPlugin) { menuItem = new JMenuItem("Request Thread Dump..."); menuItem.addActionListener(this); popup.add(menuItem); popup.addSeparator(); menuItem = new JMenuItem("Preferences"); menuItem.addActionListener(this); popup.add(menuItem); menuItem = new JMenuItem("Filters"); menuItem.addActionListener(this); popup.add(menuItem); popup.addSeparator(); menuItem = new JMenuItem("Save Logfile..."); menuItem.addActionListener(this); popup.add(menuItem); popup.addSeparator(); menuItem = new JCheckBoxMenuItem("Show Toolbar", PrefManager.get().getShowToolbar()); menuItem.addActionListener(this); popup.add(menuItem); popup.addSeparator(); menuItem = new JMenuItem("Help"); menuItem.addActionListener(this); popup.add(menuItem); popup.addSeparator(); } menuItem = new JMenuItem("About TDA"); menuItem.addActionListener(this); popup.add(menuItem); } //Add listener to the text area so the popup menu can come up. MouseListener popupListener = new PopupListener(popup); tree.addMouseListener(popupListener); }