Java Code Examples for java.awt.event.MouseEvent.getButton()
The following are Jave code examples for showing how to use
getButton() of the
java.awt.event.MouseEvent
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: Pogamut3 File: SelectableMapGLPanel.java View Source Code | 6 votes |
@Override public void mousePressed(MouseEvent e) { // we only want to select/deselect on left click, not middle click used during drag or something like that if (e.getButton() != MouseEvent.BUTTON1) { return; } // get global selection object for this map IPogamutEnvironments environments = Lookup.getDefault().lookup(IPogamutEnvironments.class); if (environments == null) { return; } IUnrealMap map = mapRenderer.getObject(); EnvironmentSelection mapSelection = environments.getEnvironmentSelection(map); // Get list of selected bots Set<IRenderableUTAgent> clickedBots = this.getAgentsAt(e.getPoint()); mapSelection.clearSelection(); for (IRenderableUTAgent selectedAgent : clickedBots) { mapSelection.addSelected(selectedAgent.getDataSource()); } }
Example 2
Project: Recaf File: MemberNodeClickListener.java View Source Code | 6 votes |
@Override public void mouseReleased(MouseEvent e) { int button = e.getButton(); // If not left-click, enforce selection at the given location if (button != MouseEvent.BUTTON1) { int index = list.locationToIndex(e.getPoint()); list.setSelectedIndex(index); } Object value = list.getSelectedValue(); // Middle-click to open editor // Right-click to open context menu if (value != null && button == MouseEvent.BUTTON2) { // TODO: Allow users to choose custom middle-click actions if (value instanceof FieldNode) { display.openDefinition((FieldNode) value); } else if (value instanceof MethodNode) { display.openOpcodes((MethodNode) value); } } else if (button == MouseEvent.BUTTON3) { createContextMenu(value, e.getX(), e.getY(), isMethodList(list)); } }
Example 3
Project: rapidminer File: PlotterMouseHandler.java View Source Code | 6 votes |
@Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (e.getClickCount() > 1) { String id = plotter.getIdForPos(e.getX(), e.getY()); if (id != null) { ObjectVisualizer visualizer = ObjectVisualizerService.getVisualizerForObject(dataTable); visualizer.startVisualization(id); } } } else if (e.getButton() == MouseEvent.BUTTON3) { plotter.setDrawRange(-1, -1, -1, -1); pressStart = null; plotter.setDragBounds(-1, -1, -1, -1); } }
Example 4
Project: incubator-netbeans File: MethodChooser.java View Source Code | 6 votes |
@Override public void mouseClicked(MouseEvent e) { if (e.isPopupTrigger()) { return; } e.consume(); int position = editorPane.viewToModel(e.getPoint()); if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON1) { if (position < 0) { return; } if (mousedIndex != -1) { selectedIndex = mousedIndex; releaseUI(true); return; } } try { int line = Utilities.getLineOffset((BaseDocument) doc, position) + 1; if (line < startLine || line > endLine) { releaseUI(false); return; } } catch (BadLocationException ex) { } }
Example 5
Project: OpenJSharp File: XToolkit.java View Source Code | 6 votes |
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 6
Project: snake_classic File: JRadialEllipseButton.java View Source Code | 5 votes |
@Override public void mousePressed(MouseEvent e){ if(e.getButton() == MouseEvent.BUTTON1 && new Ellipse2D.Double(0.0, 0.0, region.width, region.height).contains(e.getPoint())){ isPressed = true; repaint(); fireActionPerformed(new ActionEvent(thisButton, 0, null)); } }
Example 7
Project: jmt File: FastGraph.java View Source Code | 5 votes |
/** * Invoked when mouse is clicked on the graph * @param ev the click event */ public void mouseClicked(MouseEvent ev) { if (ev.getButton() == MouseEvent.BUTTON1) { leftClick(ev); } else if (ev.getButton() == MouseEvent.BUTTON3) { rightClick(ev); } else { repaint(); } }
Example 8
Project: Tarski File: mxConnectionHandler.java View Source Code | 5 votes |
/** * */ public void mouseDragged(MouseEvent e) { if (!e.isConsumed() && graphComponent.isEnabled() && isEnabled()) { // Activates the handler if (!active && first != null) { double dx = Math.abs(first.getX() - e.getX()); double dy = Math.abs(first.getY() - e.getY()); int tol = graphComponent.getTolerance(); if (dx > tol || dy > tol) { active = true; } } if (e.getButton() == 0 || (isActive() && connectPreview.isActive())) { mxCellState state = marker.process(e); if (connectPreview.isActive()) { connectPreview.update(e, marker.getValidState(), e.getX(), e.getY()); setBounds(null); e.consume(); } else { source = state; } } } }
Example 9
Project: VISNode File: JNodeContainer.java View Source Code | 5 votes |
@Override public void dragStarted(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getSource() instanceof JLayeredPane) { selectionContainer = new JNodeContainerSelection(e.getPoint()); add(selectionContainer, JLayeredPane.POPUP_LAYER); } }
Example 10
Project: JBotSim File: JNode.java View Source Code | 5 votes |
public void mousePressed(MouseEvent e) { Topology tp = node.getTopology(); if (((JTopology) getParent()).handler.ctrlPressed) { if (e.getButton() == 1) tp.selectNode(node); } else { currentButton = e.getButton(); tp.setProperty("refreshMode", tp.getRefreshMode()); tp.setRefreshMode(Topology.RefreshMode.EVENTBASED); } }
Example 11
Project: freecol File: CanvasMouseListener.java View Source Code | 5 votes |
/** * {@inheritDoc} */ public void mousePressed(MouseEvent e) { if (!e.getComponent().isEnabled()) return; final Tile tile = canvas.convertToMapTile(e.getX(), e.getY()); final Unit unit = getGUI().getActiveUnit(); final int me = (e.isPopupTrigger()) ? MouseEvent.BUTTON3 : e.getButton(); if (canvas.isGotoStarted()) canvas.stopGoto(); switch (me) { case MouseEvent.BUTTON1: // Drag and selection // Enable dragging with button 1 // @see CanvasMouseMotionListener#mouseDragged canvas.setDragPoint(e.getX(), e.getY()); canvas.requestFocus(); break; case MouseEvent.BUTTON2: // Immediate goto if (tile != null && unit != null) { canvas.startGoto(); getGUI().updateGotoPath(tile); getGUI().traverseGotoPath(); } break; case MouseEvent.BUTTON3: // Immediate tile popup canvas.showTilePopup(tile, e.getX(), e.getY()); break; default: break; } }
Example 12
Project: OpenJSharp File: XToolkit.java View Source Code | 5 votes |
static boolean isLeftMouseButton(MouseEvent me) { switch (me.getID()) { case MouseEvent.MOUSE_PRESSED: case MouseEvent.MOUSE_RELEASED: return (me.getButton() == MouseEvent.BUTTON1); case MouseEvent.MOUSE_ENTERED: case MouseEvent.MOUSE_EXITED: case MouseEvent.MOUSE_CLICKED: case MouseEvent.MOUSE_DRAGGED: return ((me.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0); } return false; }
Example 13
Project: openjdk-jdk10 File: XMBeanAttributes.java View Source Code | 5 votes |
@Override public void mousePressed(MouseEvent e) { if(e.getButton() == MouseEvent.BUTTON1) { if(e.getClickCount() >= 2) { int row = XMBeanAttributes.this.getSelectedRow(); int col = XMBeanAttributes.this.getSelectedColumn(); if(col != VALUE_COLUMN) return; if(col == -1 || row == -1) return; XMBeanAttributes.this.updateZoomedCell(row, col); } } }
Example 14
Project: agar.io File: EZ.java View Source Code | 5 votes |
@Override public void mouseReleased(MouseEvent me) { if (me.getButton() == 1) { //left mlbPressed = false; mlbDown = false; mlbReleased = true; mlbRTime = -1; } else if(me.getButton() == 3) { //right mrbPressed = false; mrbDown = false; mrbReleased = true; mrbRTime = -1; } }
Example 15
Project: QN-ACTR-Release File: FuzzyKSingleClusterScatter.java View Source Code | 4 votes |
public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { popup.show(p, e.getX(), e.getY()); } }
Example 16
Project: jmt File: KFuzzyScatter.java View Source Code | 4 votes |
public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { popup.show(p, e.getX(), e.getY()); } }
Example 17
Project: jmt File: EnlargePDF.java View Source Code | 4 votes |
public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { pop.show(EnlargePDF.this, e.getX(), e.getY()); } }
Example 18
Project: incubator-netbeans File: TreeTable.java View Source Code | 4 votes |
private boolean shouldIgnore(MouseEvent e) { return !table.isEnabled() || ((e.getButton() == MouseEvent.BUTTON3) && (e.getClickCount() == 1) && !e.isPopupTrigger()); }
Example 19
Project: QN-ACTR-Release File: EnlargeQQPlot.java View Source Code | 4 votes |
public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { pop.show(EnlargeQQPlot.this, e.getX(), e.getY()); } }
Example 20
Project: QN-ACTR-Release File: Scatter.java View Source Code | 4 votes |
public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { popup.show(p, e.getX(), e.getY()); } }