List of usage examples for java.awt.event MouseEvent BUTTON3
int BUTTON3
To view the source code for java.awt.event MouseEvent BUTTON3.
Click Source Link
From source file:pt.lsts.neptus.console.plugins.ImageLayers.java
@Override public void mouseClicked(MouseEvent event, StateRenderer2D source) { if (event.getButton() == MouseEvent.BUTTON3) { JPopupMenu popup = new JPopupMenu(); popup.add("Add layer from file").addActionListener(new ActionListener() { @Override/* www . j ava2s . c o m*/ public void actionPerformed(ActionEvent e) { JFileChooser chooser = GuiUtils.getFileChooser(lastDir, I18n.text("Neptus image layers"), "layer"); int op = chooser.showOpenDialog(getConsole()); if (op != JFileChooser.APPROVE_OPTION) return; lastDir = chooser.getSelectedFile().getParent(); Future<ImageLayer> il = addLayer(chooser.getSelectedFile()); try { il.get(); } catch (Exception ex) { GuiUtils.errorMessage(getConsole(), ex); } } }); if (!layers.isEmpty()) { JMenu menu = new JMenu("Remove"); JMenu menu2 = new JMenu("Opacity"); for (final ImageLayer l : layers) { menu.add(l.getName()).addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { layers.remove(l); layerFiles = StringUtils.join(layers, ","); rebuildControls(); } }); menu2.add(l.getName() + "(" + l.getTransparency() + ")") .addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String s = JOptionPane.showInputDialog(getConsole(), "Enter opacity (1 for opaque, 0 for invisible)", l.getTransparency()); if (s == null) return; try { double val = Double.parseDouble(s); if (val < 0) throw new Exception("Value must be greater or equal to 0"); if (val > 1) throw new Exception("Value must be less or equal to 1"); l.setTransparency(val); } catch (Exception ex) { GuiUtils.errorMessage(getConsole(), ex); } } }); } popup.add(menu); popup.add(menu2); } popup.show(source, event.getX(), event.getY()); } }
From source file:eu.europa.ec.markt.dss.applet.view.validationpolicy.EditView.java
private void registerMouseListener(final JTree tree) { MouseListener mouseAdapter = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent.getButton() == MouseEvent.BUTTON3) { final int selectedRow = tree.getRowForLocation(mouseEvent.getX(), mouseEvent.getY()); final TreePath selectedPath = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY()); if (selectedRow != -1) { final XmlDomAdapterNode clickedItem = (XmlDomAdapterNode) selectedPath .getLastPathComponent(); final boolean isLeaf = tree.getModel().isLeaf(selectedPath.getLastPathComponent()); // Do nothing on root element if (selectedPath.getPathCount() > 1) { // find the allowed actions, to know if a popup menu should be displayed and the content of the popup menu + action handlers if (clickedItem.node instanceof Element) { nodeActionAdd(mouseEvent, selectedRow, selectedPath, clickedItem, tree); } else if (isLeaf) { valueLeafActionEdit(mouseEvent, selectedPath, clickedItem, tree); }/* w w w.ja v a 2 s . com*/ } } } } }; tree.addMouseListener(mouseAdapter); }
From source file:eu.europa.esig.dss.applet.view.validationpolicy.EditView.java
private void registerMouseListener(final JTree tree) { MouseListener mouseAdapter = new MouseAdapter() { @Override//from ww w . ja v a2 s. c o m public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent.getButton() == MouseEvent.BUTTON3) { final int selectedRow = tree.getRowForLocation(mouseEvent.getX(), mouseEvent.getY()); final TreePath selectedPath = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY()); if (selectedRow != -1) { final XmlDomAdapterNode clickedItem = (XmlDomAdapterNode) selectedPath .getLastPathComponent(); final boolean isLeaf = tree.getModel().isLeaf(selectedPath.getLastPathComponent()); // Do nothing on root element if (selectedPath.getPathCount() > 1) { // find the allowed actions, to know if a popup menu should be displayed and the content of the popup menu + action handlers if (clickedItem.node instanceof Element) { nodeActionAdd(mouseEvent, selectedRow, selectedPath, clickedItem, tree); } else if (isLeaf) { valueLeafActionEdit(mouseEvent, selectedPath, clickedItem, tree); } } } } } }; tree.addMouseListener(mouseAdapter); }
From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java
public void mousePressed(MouseEvent e) { if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) { if (this.coElutionRegion == null) { shifted = true;/* w w w .j a v a 2s . com*/ Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY()); if (screenDataArea != null) { this.coElutionStart = getPointInRectangle(e.getX(), e.getY(), screenDataArea); } else { this.coElutionStart = null; } } } else { _cp.mousePressed(e); } }
From source file:org.openconcerto.erp.panel.ITreeSelection.java
public void mousePressed(MouseEvent e) { TreePath path = this.getSelectionPath(); if (path != null) { Object o = path.getLastPathComponent(); int id = 1; if (e.getButton() == MouseEvent.BUTTON3) { final int idSelect = getSelectedID(); // Ajouter, supprimer, modifier un lment dans l'arbre JPopupMenu menu = new JPopupMenu(); menu.add(new AbstractAction("Ajouter un lment") { public void actionPerformed(ActionEvent e) { addElement(idSelect); }/*from w ww . java 2 s . com*/ }); if (idSelect > 1) { menu.add(new AbstractAction("Modifier") { public void actionPerformed(ActionEvent e) { modifyElement(idSelect); } }); menu.add(new AbstractAction("Supprimer") { public void actionPerformed(ActionEvent e) { removeElement(idSelect); } }); } menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y); } } }
From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java
@Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3 || this.popupMenu.isShowing()) { return;/*from w w w .j av a 2 s . co m*/ } //testLog.append("Mouse pressed: " + e.getX() + ", " + e.getY() + "\n"); startX = e.getX(); startY = e.getY(); endX = e.getX(); endY = e.getY(); // if (selectRectangle != null) // { // Graphics2D g2 = (Graphics2D) this.getGraphics(); // drawSelectRectangle(g2); // this.selectRectangle = new Rectangle2D.Double(e.getX(), e.getY(), 0, 0); // } this.isNewRectangle = true; this.x = e.getX(); this.y = e.getY(); this.width = 0; this.height = 0; repaint(); }
From source file:it.unibas.spicygui.vista.listener.MyMouseEventListener.java
private void dispacciaEvento(Component com, MouseEvent e, Point point, boolean draggedEvent) { if (com == null) { com = SwingUtilities.getDeepestComponentAt(pannelloPrincipale, point.x, point.y); }/*from w w w . ja va 2 s. co m*/ Point componentPoint = SwingUtilities.convertPoint(component, e.getPoint(), com); if (com != null) { if (com instanceof JTree) { TreePath treePath = ((JTree) com).getPathForLocation(componentPoint.x, componentPoint.y); if (treePath == null || draggedEvent) { jLayeredPane.moveToFront(component); component.updateUI(); if (e.getButton() == MouseEvent.BUTTON3) { return; } } } com.dispatchEvent(new MouseEvent(com, e.getID(), e.getWhen(), e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger())); jLayeredPane.moveToFront(component); component.updateUI(); } jLayeredPane.moveToFront(component); component.updateUI(); }
From source file:at.ac.tuwien.ibk.biqini.pep.gui.PEPGUI.java
public PEPGUI(String arg0, Vector<IBandwidthTracer> qosRules) { super(arg0);/*w w w .ja v a 2 s . c om*/ // initiate all collections tsc = new TimeSeriesCollection[MAXCHARTS]; charts = new JFreeChart[MAXCHARTS]; positions = new Vector<Integer>(); chartPosition = new Hashtable<String, Integer>(); for (int i = 0; i < MAXCHARTS; i++) positions.add(i); allSessions = new Hashtable<String, IBandwidthTracer>(); // fill the BandwidthGenerator with the ongoing QoSRules bandwidthGenerator = new BandwidthGenerator(); Enumeration<IBandwidthTracer> enbandwidth = qosRules.elements(); while (enbandwidth.hasMoreElements()) { IBandwidthTracer b = enbandwidth.nextElement(); allSessions.put(b.getName(), b); bandwidthGenerator.add(b); } gridBagLayout = new GridBagLayout(); //insert the list with all QoS rules GridBagConstraints c = new GridBagConstraints(); c.weighty = 9; c.weightx = 2.0; c.gridheight = MAXCHARTS; c.fill = GridBagConstraints.BOTH; content = new JPanel(gridBagLayout); qoSRuleList = new JList(allSessions.keySet().toArray()); qoSRuleList.setPreferredSize(new java.awt.Dimension(200, 600)); qoSRuleList.setBorder(BorderFactory.createRaisedBevelBorder()); // set a MouseListner on the List MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int index = qoSRuleList.locationToIndex(e.getPoint()); addStream(allSessions.get(allSessions.keySet().toArray()[index])); } if (e.getButton() == MouseEvent.BUTTON3) { int index = qoSRuleList.locationToIndex(e.getPoint()); removeStream(allSessions.get(allSessions.keySet().toArray()[index])); } } }; qoSRuleList.addMouseListener(mouseListener); // place all parts at the content pane gridBagLayout.setConstraints(qoSRuleList, c); content.add(qoSRuleList); setContentPane(content); content.setSize(1000, 800); //create all GUI aspects for our Charts insertAllCharts(); //Start the thread that fills up our time series periodicBandwidthReader = new Thread(bandwidthGenerator); periodicBandwidthReader.setName("data-collector"); periodicBandwidthReader.start(); }
From source file:org.openestate.tool.helloworld.HelloWorldFrameSidebarExtension.java
@Override public JComponent createComponent() { // create the component, that is shown in the sidebar final HelloWorldList list = new HelloWorldList(); list.setModel(ObjectUtils.defaultIfNull(createListModel(), new DefaultListModel<>())); list.setCellRenderer(new HelloWorldListRenderer()); // register keyboard events list.addKeyListener(new KeyAdapter() { @Override/* w ww .j a va 2 s .c o m*/ public void keyPressed(KeyEvent e) { if (!list.isEnabled()) return; // ENTER was pressed if (e.getKeyCode() == KeyEvent.VK_ENTER) { DbHelloWorldObject object = list.getSelectedValue(); if (object != null) new HelloWorldPlugin.ObjectFormAction(object.id).actionPerformed(null); } } }); // register mouse events list.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (!list.isEnabled()) return; // single click with the right mouse button if (e.getButton() == MouseEvent.BUTTON3 && e.getClickCount() == 1) { // fetch the clicked element int index = list.locationToIndex(e.getPoint()); if (index >= 0) list.setSelectedIndex(index); // show popup menu with further actions DbHelloWorldObject object = list.getSelectedValue(); JPopupMenu popup = createActionMenu(object); if (popup != null) popup.show(list, e.getPoint().x, e.getPoint().y); } // double click with the left mouse button else if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { DbHelloWorldObject object = list.getSelectedValue(); if (object != null) new HelloWorldPlugin.ObjectFormAction(object.id).actionPerformed(null); } } }); return list; }
From source file:de.fhbingen.wbs.wpOverview.tabs.APCalendarPanel.java
/** * Initialize the work package calendar panel inclusive the listeners. *//*from www. jav a 2s . c om*/ private void init() { List<Workpackage> userWp = new ArrayList<Workpackage>(WpManager.getUserWp(WPOverview.getUser())); Collections.sort(userWp, new APLevelComparator()); dataset = createDataset(userWp); chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); final JPopupMenu popup = new JPopupMenu(); JMenuItem miSave = new JMenuItem(LocalizedStrings.getButton().save(LocalizedStrings.getWbs().timeLine())); miSave.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent arg0) { JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new ExtensionAndFolderFilter("jpg", "jpeg")); //NON-NLS chooser.setSelectedFile(new File("chart-" //NON-NLS + System.currentTimeMillis() + ".jpg")); int returnVal = chooser.showSaveDialog(reference); if (returnVal == JFileChooser.APPROVE_OPTION) { try { File outfile = chooser.getSelectedFile(); ChartUtilities.saveChartAsJPEG(outfile, chart, chartPanel.getWidth(), chartPanel.getWidth()); Controller.showMessage( LocalizedStrings.getMessages().timeLineSaved(outfile.getCanonicalPath())); } catch (IOException e) { Controller.showError(LocalizedStrings.getErrorMessages().timeLineExportError()); } } } }); popup.add(miSave); chartPanel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { popup.show(e.getComponent(), e.getX(), e.getY()); } } }); chartPanel.setMinimumDrawHeight(50 + 15 * userWp.size()); chartPanel.setMaximumDrawHeight(50 + 15 * userWp.size()); chartPanel.setMaximumDrawWidth(9999); chartPanel.setPreferredSize( new Dimension((int) chartPanel.getPreferredSize().getWidth(), 50 + 15 * userWp.size())); chartPanel.setPopupMenu(null); this.setLayout(new BorderLayout()); this.removeAll(); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 1; constraints.weighty = 1; constraints.anchor = GridBagConstraints.NORTHWEST; panel.add(chartPanel, constraints); panel.setBackground(Color.white); this.add(panel, BorderLayout.CENTER); GanttRenderer.setDefaultShadowsVisible(false); GanttRenderer.setDefaultBarPainter(new BarPainter() { @Override public void paintBar(final Graphics2D g, final BarRenderer arg1, final int row, final int col, final RectangularShape rect, final RectangleEdge arg5) { String wpName = (String) dataset.getColumnKey(col); int i = 0; int spaceCount = 0; while (wpName.charAt(i++) == ' ' && spaceCount < 17) { spaceCount++; } g.setColor(new Color(spaceCount * 15, spaceCount * 15, spaceCount * 15)); g.fill(rect); g.setColor(Color.black); g.setStroke(new BasicStroke()); g.draw(rect); } @Override public void paintBarShadow(final Graphics2D arg0, final BarRenderer arg1, final int arg2, final int arg3, final RectangularShape arg4, final RectangleEdge arg5, final boolean arg6) { } }); ((CategoryPlot) chart.getPlot()).setRenderer(new GanttRenderer() { private static final long serialVersionUID = -6078915091070733812L; public void drawItem(final Graphics2D g2, final CategoryItemRendererState state, final Rectangle2D dataArea, final CategoryPlot plot, final CategoryAxis domainAxis, final ValueAxis rangeAxis, final CategoryDataset dataset, final int row, final int column, final int pass) { super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass); } }); }