Java Code Examples for java.awt.event.MouseEvent#BUTTON3

The following examples show how to use java.awt.event.MouseEvent#BUTTON3 . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public void mouseClicked(MouseEvent e) {
	
	for (int i=1; i< size; i++) {
		if (e.getSource() == row[i]) {
			if (rtValue[i].getText().equalsIgnoreCase(noValue)) {
				// dont open graph
			} else
				if (e.isControlDown() || e.getButton() == MouseEvent.BUTTON3)
					displayGraph(i, GraphFrame.EARTH_PLOT);
				else
					displayGraph(i, GraphFrame.GRAPH_PLOT);

		}
	}
}
 
Example 2
Source Project: workcraft   File: XmasSimulationTool.java    License: MIT License 6 votes vote down vote up
@Override
public void mousePressed(GraphEditorMouseEvent e) {
    Transition transition = null;
    if (e.getButton() == MouseEvent.BUTTON3) {
        transition = getExcitedTransition(converter.getClockStg().fallList);
    }
    if (e.getButton() == MouseEvent.BUTTON1) {
        Point2D posRoot = e.getPosition();
        Node deepestNode = HitMan.hitDeepest(posRoot, e.getModel().getRoot(),
                node -> node instanceof VisualTransformableNode);

        if (deepestNode instanceof VisualTransformableNode) {
            AffineTransform rootToLocalTransform = TransformHelper.getTransform(e.getModel().getRoot(), deepestNode);
            Point2D posLocal = rootToLocalTransform.transform(posRoot, null);
            Point2D posNode = ((VisualTransformableNode) deepestNode).getParentToLocalTransform().transform(posLocal, null);
            transition = getClickedComponentTransition(deepestNode, posNode);
        }
    }
    if (transition != null) {
        executeTransition(e.getEditor(), transition);
        Transition t = null;
        while ((t = getExcitedTransition(skipTransitions)) != null) {
            executeTransition(e.getEditor(), t);
        }
    }
}
 
Example 3
/**
 * Sets the mouse button that is used for moving the map. Possible values are:
 * <ul>
 * <li>{@link MouseEvent#BUTTON1} (left mouse button)</li>
 * <li>{@link MouseEvent#BUTTON2} (middle mouse button)</li>
 * <li>{@link MouseEvent#BUTTON3} (right mouse button)</li>
 * </ul>
 *
 * @param movementMouseButton
 */
public void setMovementMouseButton(int movementMouseButton) {
	this.movementMouseButton = movementMouseButton;
	switch (movementMouseButton) {
	case MouseEvent.BUTTON1:
		movementMouseButtonMask = MouseEvent.BUTTON1_DOWN_MASK;
		break;
	case MouseEvent.BUTTON2:
		movementMouseButtonMask = MouseEvent.BUTTON2_DOWN_MASK;
		break;
	case MouseEvent.BUTTON3:
		movementMouseButtonMask = MouseEvent.BUTTON3_DOWN_MASK;
		break;
	default:
		throw new RuntimeException("Unsupported button");
	}
}
 
Example 4
@Override
public void mouseClicked(final MouseEvent e) {
    if (e.getClickCount() > 1) {
        if (e.getButton() == MouseEvent.BUTTON1) {
            removeSelectedFromDeck();
        } else if (e.getButton() == MouseEvent.BUTTON3) {
            final List<MagicCardDefinition> deckCards = deckTable.getSelectedCards();
            if (deckCards.size() > 0) {
                deck.addAll(deckCards);
                updateDeck();
            }
        }
    }
    if (e.getButton() == MouseEvent.BUTTON3) {
        final JTable table = (JTable) (e.getSource());
        final int row = table.rowAtPoint(e.getPoint());
        table.clearSelection();
        table.addRowSelectionInterval(row, row);
    }
}
 
Example 5
Source Project: marathonv5   File: JSONScriptElement.java    License: Apache License 2.0 6 votes vote down vote up
private String enscriptRawMouseClick() {
    boolean popupTrigger = event.getInt("button") == MouseEvent.BUTTON3;
    int clickCount = event.getInt("clickCount");
    int x = event.getInt("x");
    int y = event.getInt("y");
    String mtext = event.getString("modifiersEx");
    String method = "click";
    if (popupTrigger) {
        method = "rightclick";
    }
    if ("".equals(mtext)) {
        return Indent.getIndent()
                + RecordingScriptModel.getModel().getScriptCodeForGenericAction(method, "", name, clickCount, x, y);
    }
    return Indent.getIndent()
            + RecordingScriptModel.getModel().getScriptCodeForGenericAction(method, "", name, clickCount, x, y, mtext);
}
 
Example 6
Source Project: openjdk-8   File: XToolkit.java    License: GNU General Public License v2.0 6 votes vote down vote up
static boolean isRightMouseButton(MouseEvent me) {
    int numButtons = ((Integer)getDefaultToolkit().getDesktopProperty("awt.mouse.numButtons")).intValue();
    switch (me.getID()) {
      case MouseEvent.MOUSE_PRESSED:
      case MouseEvent.MOUSE_RELEASED:
          return ((numButtons == 2 && me.getButton() == MouseEvent.BUTTON2) ||
                   (numButtons > 2 && me.getButton() == MouseEvent.BUTTON3));
      case MouseEvent.MOUSE_ENTERED:
      case MouseEvent.MOUSE_EXITED:
      case MouseEvent.MOUSE_CLICKED:
      case MouseEvent.MOUSE_DRAGGED:
          return ((numButtons == 2 && (me.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) ||
                  (numButtons > 2 && (me.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0));
    }
    return false;
}
 
Example 7
/**
 * Creates an AWT <code>MouseEvent</code> from a swt event.
 * This method helps passing SWT mouse event to awt components.
 * @param event The swt event.
 * @return A AWT mouse event based on the given SWT event.
 */
public static MouseEvent toAwtMouseEvent(org.eclipse.swt.events.MouseEvent event) {
    int button = MouseEvent.NOBUTTON;
    switch (event.button) {
    case 1: button = MouseEvent.BUTTON1; break;
    case 2: button = MouseEvent.BUTTON2; break;
    case 3: button = MouseEvent.BUTTON3; break;
    }
    int modifiers = 0;
    if ((event.stateMask & SWT.CTRL) != 0) {
        modifiers |= InputEvent.CTRL_DOWN_MASK;
    }
    if ((event.stateMask & SWT.SHIFT) != 0) {
        modifiers |= InputEvent.SHIFT_DOWN_MASK;
    }
    if ((event.stateMask & SWT.ALT) != 0) {
        modifiers |= InputEvent.ALT_DOWN_MASK;
    }
    MouseEvent awtMouseEvent = new MouseEvent(DUMMY_PANEL, event.hashCode(),
            event.time, modifiers, event.x, event.y, 1, false, button);
    return awtMouseEvent;
}
 
Example 8
@Override
public void mouseClicked(final MouseEvent e) {
    // On double click, retrieve the selection:
    if (e.getButton() == MouseEvent.BUTTON1) {
        if (e.getClickCount() == 2) {
            retrieveSelection();
        }
    } // Right click: open context menu on the named selection 'under' the mouse pointer:
    else if (e.getButton() == MouseEvent.BUTTON3) {
        lstNamedSelections.setSelectedIndex(lstNamedSelections.locationToIndex(e.getPoint()));

        boolean isEnabled = true;
        if (lstNamedSelections.getSelectedIndex() == 0) {
            isEnabled = false;
        }
        for (Component c : popContext.getComponents()) {
            c.setEnabled(isEnabled);
        }

        // Update the context menu based on the whether or not the selection is a protected one:
        final boolean locked = ((NamedSelection) lstNamedSelections.getSelectedValue()).isLocked();
        mnuCheckLocked.setSelected(locked);
        mnuDescription.setEnabled(!locked);
        mnuOverwrite.setEnabled(!locked);
        mnuRemove.setEnabled(!locked);
        mnuRename.setEnabled(!locked);
    }
}
 
Example 9
/**
 * Shows the context menu when right click occurs within the dataTable
 * component.
 *
 * @param evt
 */
private void dataTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_dataTableMouseClicked
    //BUTTON3 is Right click
    if (evt.getButton() == MouseEvent.BUTTON3) {
        int xOffset = evt.getX();
        int yOffset = evt.getY();
        copyClipboard.setMousePosition(evt.getPoint());
        rightClickMenu.show(dataTable, xOffset, yOffset);
    }

}
 
Example 10
@Override
public void mousePressed(MouseEvent e) {
	if(e.getButton() == MouseEvent.BUTTON1)
		leftPressed = true;
	else if(e.getButton() == MouseEvent.BUTTON3)
		rightPressed = true;
}
 
Example 11
/**
 * {@inheritDoc}
 */
public void mousePressed(MouseEvent e) {
    if (!e.getComponent().isEnabled()) return;

    if (e.isPopupTrigger()) {
        getGUI().showTilePopup(e.getX(), e.getY());
        return;
    }

    switch (e.getButton()) {
    case MouseEvent.BUTTON1: 
        // If we have GoTo mode enabled then GoTo takes precedence
        if (getGUI().isGotoStarted()) {
            getGUI().performGoto(e.getX(), e.getY());
            break;
        }

        // Drag and selection
        // Enable dragging with button 1
        // @see CanvasMouseMotionListener#mouseDragged
        getGUI().prepareDrag(e.getX(), e.getY());
        break;
    case MouseEvent.BUTTON2: // Immediate goto
        getGUI().performGoto(e.getX(), e.getY());
        break;
    case MouseEvent.BUTTON3: // Immediate tile popup
        getGUI().showTilePopup(e.getX(), e.getY());
        break;
    default:
        break;
    }
}
 
Example 12
Source Project: openAGV   File: TreeMouseAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
  JTree objectTree = treeView.getTree();
  TreePath selPath = objectTree.getPathForLocation(e.getX(), e.getY());
  if (selPath == null) {
    if (e.getButton() == MouseEvent.BUTTON3) {
      showPopupMenu(e.getX(), e.getY());
    }
  }
  else {
    UserObject userObject = getUserObject(selPath);

    if (e.getButton() == MouseEvent.BUTTON3) {
      evaluateRightClick(e, userObject, treeView.getSelectedItems());
    }
    else if (e.getButton() == MouseEvent.BUTTON1) {

      //This Method tells the OpenTCSView what elements are currently selected
      ((AbstractUserObject) userObject).selectMultipleObjects();

      if (e.getClickCount() == 2) {
        userObject.doubleClicked();
      }

    }

  }

}
 
Example 13
Source Project: jaamsim   File: ObjectSelector.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {

	if(e.getButton() != MouseEvent.BUTTON3)
		return;

	if(currentEntity == null)
		return;

	// Right mouse click on a movable DisplayEntity
	menu.removeAll();
	ContextMenu.populateMenu(menu, currentEntity, -1, e.getComponent(), e.getX(), e.getY());
	menu.show(e.getComponent(), e.getX(), e.getY());
}
 
Example 14
Source Project: ET_Redux   File: EvolutionPlotPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent evt) {
    super.mousePressed(evt);
    if ((evt.getX() >= leftMargin)
            && (evt.getX() <= graphWidth + leftMargin)
            && (evt.getY() >= topMargin)
            && (evt.getY() <= graphHeight + topMargin)) {

        if (evt.isPopupTrigger() || evt.getButton() == MouseEvent.BUTTON3) {

            putInImageModePan();

            //Create the popup menu.
            JPopupMenu popup = new JPopupMenu();

            // Jan 2011 show coordinates fyi
            double x = convertMouseXToValue(evt.getX());
            double y = convertMouseYToValue(evt.getY());

            JMenuItem menuItem = new JMenuItem("Toggle Y-axis units");
            menuItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent arg0) {
                    yAxisDisplayAsDeltaUnits = !yAxisDisplayAsDeltaUnits;
                    repaint();
                }
            });
            popup.add(menuItem);

            popup.show(evt.getComponent(), evt.getX(), evt.getY());
        }
    }
}
 
Example 15
@Override
public void mousePressed(MouseEvent e) {
	if(e.getButton() == MouseEvent.BUTTON1)
		leftPressed = true;
	else if(e.getButton() == MouseEvent.BUTTON3)
		rightPressed = true;
}
 
Example 16
Source Project: marathonv5   File: EventQueueDevice.java    License: Apache License 2.0 5 votes vote down vote up
private void storeMouseDown(int button) {
    if (button == MouseEvent.BUTTON1) {
        button1Pressed = true;
    }
    if (button == MouseEvent.BUTTON2) {
        button2Pressed = true;
    }
    if (button == MouseEvent.BUTTON3) {
        button3Pressed = true;
    }
}
 
Example 17
Source Project: xdm   File: PopupAdapter.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void mouseReleased(MouseEvent e) {
	if (e.getButton() == MouseEvent.BUTTON3 || SwingUtilities.isRightMouseButton(e) || e.isPopupTrigger()
			|| XDMUtils.isMacPopupTrigger(e)) {
		if (e.getSource() instanceof JTextComponent) {
			popup.show(txt, e.getX(), e.getY());
		}
	}
}
 
Example 18
@Override
public void mouseClicked(MouseEvent e) {
    TreePath path = tree.getPathForLocation(e.getX(), e.getY());

    if (path == null) {
        return;
    }

    if (currentSelectedBugLeaf == path.getLastPathComponent()) {
        // sync mainFrame if user just clicks on the same bug
        mainFrame.syncBugInformation();
    }

    if ((e.getButton() == MouseEvent.BUTTON3) || (e.getButton() == MouseEvent.BUTTON1 && e.isControlDown())) {

        if (tree.getModel().isLeaf(path.getLastPathComponent())) {
            tree.setSelectionPath(path);
            bugPopupMenu.show(tree, e.getX(), e.getY());
        } else {
            tree.setSelectionPath(path);
            if (!(path.getParentPath() == null)) {
                // path is null, the
                // root was selected,
                // don't allow them to
                // filter out the root.
                branchPopupMenu.show(tree, e.getX(), e.getY());
            }
        }
    }
}
 
Example 19
Source Project: mochadoom   File: event_t.java    License: GNU General Public License v3.0 5 votes vote down vote up
static int mouseBits(int button) {
    switch(button) {
        case MouseEvent.BUTTON1:
            return MOUSE_LEFT;
        case MouseEvent.BUTTON2:
            return MOUSE_RIGHT;
        case MouseEvent.BUTTON3:
            return MOUSE_MID;
    }
    
    return 0;
}
 
Example 20
private int getActingMouseButton(final int button) {
	if (MouseEvent.BUTTON1 == button) {
		return NetworkMouseControlMessage.BUTTON1;
	}
	if (MouseEvent.BUTTON2 == button) {
		return NetworkMouseControlMessage.BUTTON2;
	}
	if (MouseEvent.BUTTON3 == button) {
		return NetworkMouseControlMessage.BUTTON3;
	}
	return NetworkMouseControlMessage.UNDEFINED;
}