List of usage examples for java.awt.event MouseEvent getButton
public int getButton()
From source file:lu.fisch.unimozer.Diagram.java
@Override public void mousePressed(MouseEvent e) { if (isEnabled() && e.getButton() == MouseEvent.BUTTON1) { if (mode == MODE_EXTENDS) { // get the clicked point mousePoint = e.getPoint();/*from ww w.j a v a 2s.co m*/ mousePressed = true; // get clicked class extendsFrom = getMouseClass(mousePoint); extendsDragPoint = e.getPoint(); if (extendsFrom == null) { setMode(MODE_SELECT); frame.updateMode(); } } else { if (e.getButton() == MouseEvent.BUTTON1) mousePressed = true; // get the clicked point mousePoint = e.getPoint(); // get clicked package getMousePackage(mousePoint); // get clicked class MyClass clickClass = getMouseClass(mousePoint); if (clickClass != null) mouseRelativePoint = clickClass.getRelative(mousePoint); else if (mousePackage != null) { mouseRelativePoint = mousePoint; } // load the clicked class loadClickedClass(e); } } }
From source file:app.RunApp.java
/** * Action when mouse released of Co-ocurrence panel * /*from w w w.ja v a 2 s . c o m*/ * @param evt Event */ private void panelCoOcurrenceMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_panelCoOcurrenceMouseReleased if (evt.getButton() == MouseEvent.BUTTON3) { jPopupMenu1.removeAll(); JMenuItem saver = new JMenuItem("Save as..."); saver.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { try { saveCoocurrenceGraph(); } catch (AWTException | IOException ex) { Logger.getLogger(RunApp.class.getName()).log(Level.SEVERE, null, ex); } } }); jPopupMenu1.add(saver); jPopupMenu1.show(evt.getComponent(), evt.getX(), evt.getY()); } }