Java Code Examples for java.awt.event.MouseEvent.BUTTON2

The following are Jave code examples for showing how to use BUTTON2 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: jdk8u-jdk   File: XToolkit.java   View Source Code Vote up 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 2
Project: Recaf   File: OpcodeMouseListener.java   View Source Code Vote up 6 votes
@Override
public void mouseReleased(MouseEvent e) {
	int button = e.getButton();
	if (list.getSelectedIndices().length <= 1) {
		// 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();
	if (value == null) {
		return;
	}
	if (button == MouseEvent.BUTTON3) {
		createContextMenu((AbstractInsnNode) value, e.getX(), e.getY());
	} else if (button == MouseEvent.BUTTON2) {
		createEdit((AbstractInsnNode) value, e.getX(), e.getY());
	}
}
 
Example 3
Project: Logisim   File: Canvas.java   View Source Code Vote up 6 votes
@Override
public void mouseReleased(MouseEvent e) {
	if ((e.getButton() == MouseEvent.BUTTON1 && viewport.zoomButtonVisible
			&& AutoZoomButtonClicked(viewport.getSize(), e.getX() * getZoomFactor() - getHorizzontalScrollBar(),
					e.getY() * getZoomFactor() - getVerticalScrollBar())
			&& viewport.zoomButtonColor != defaultzoomButtonColor)
			|| e.getButton() == MouseEvent.BUTTON2 && e.getClickCount() == 2) {
		autoZoomCenter();
	} else {
		if (drag_tool != null) {
			drag_tool.mouseReleased(Canvas.this, getGraphics(), e);
			drag_tool = null;
		}

		Tool tool = proj.getTool();
		if (tool != null) {
			tool.mouseMoved(Canvas.this, getGraphics(), e);
			setCursor(tool.getCursor());
		}
		completeAction();
	}
	viewport.zoomButtonColor = defaultzoomButtonColor;
}
 
Example 4
Project: openjdk-jdk10   File: XToolkit.java   View Source Code Vote up 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 5
Project: jmt   File: Convex3DGraph.java   View Source Code Vote up 6 votes
public void mouseReleased(MouseEvent evt) {
	switch (evt.getButton()) {
	case MouseEvent.BUTTON1: {
		mouseLeft = false;
		break;
	}
	case MouseEvent.BUTTON2: {
		mouseRight = false;
		break;
	}
	}
	if (!mouseLeft && !mouseRight) {
		mouseMode = MouseMode.NONE;
	}
	// This is the last mouse action, so keep track of it.
	mouseEnd.x = evt.getX();
	mouseEnd.y = evt.getY();
	mouseDelta = new Point(mouseEnd.x - mouseStart.x, mouseEnd.y
			- mouseStart.y);
	repaint();
}
 
Example 6
Project: OpenJSharp   File: XToolkit.java   View Source Code Vote up 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 7
Project: Logisim   File: AppearanceCanvas.java   View Source Code Vote up 6 votes
@Override
public void mouseReleased(MouseEvent arg0) {
	if (arg0.getButton() == MouseEvent.BUTTON2 && arg0.getClickCount() == 1) {
		setCursor(cursor);
		this.mooving = false;
	} else if ((arg0.getButton() == MouseEvent.BUTTON1 && viewport.zoomButtonVisible
			&& com.cburch.logisim.gui.main.Canvas.AutoZoomButtonClicked(viewport.getSize(),
					arg0.getX() * getZoomFactor() - getHorizzontalScrollBar(),
					arg0.getY() * getZoomFactor() - getVerticalScrollBar())
			&& viewport.zoomButtonColor != com.cburch.logisim.gui.main.Canvas.defaultzoomButtonColor)
			|| arg0.getButton() == MouseEvent.BUTTON2 && arg0.getClickCount() == 2) {
		autoZoomCenter();
	}
	if (getTool() == null)
		setTool(tempTool);
	viewport.zoomButtonColor = com.cburch.logisim.gui.main.Canvas.defaultzoomButtonColor;
}
 
Example 8
Project: TopDownGame   File: ControlMouse.java   View Source Code Vote up 5 votes
@Override
public void mouseReleased(MouseEvent e)
{
	if(!inst.GAME_STARTED)
	{
		;
	}
	else
	{
		switch(e.getButton())
		{
			case MouseEvent.BUTTON1:
			{
				keys.MOUSE_LEFT = false;
				break;
			}
			case MouseEvent.BUTTON2:
			{
				keys.MOUSE_RIGHT = false;
				break;
			}
			case MouseEvent.BUTTON3:
			{
				break;
			}
		}
	}
}
 
Example 9
Project: JBotSim   File: JNode.java   View Source Code Vote up 5 votes
public void mouseReleased(MouseEvent e) {
    Topology tp = node.getTopology();
    if (tp.hasProperty("refreshMode"))
        tp.setRefreshMode((Topology.RefreshMode) tp.getProperty("refreshMode"));
    if (destination != null) {
        node.getTopology().addLink(new Link(node, destination));
        destination = null;
    } else {
        if (e.getButton() == MouseEvent.BUTTON3)
            node.getTopology().removeNode(node);
        else if (e.getButton() == MouseEvent.BUTTON2)
            node.getTopology().selectNode(node);
    }
    currentButton = 1;
}
 
Example 10
Project: Mafia   File: MouseInput.java   View Source Code Vote up 5 votes
@Override
public void mousePressed(MouseEvent event) {
	if(event.getButton() == MouseEvent.BUTTON1) {
		isPrimaryPressed = true;
		
	} else if(event.getButton() == MouseEvent.BUTTON2) {
		isMiddlePressed = true;
		
	} else if(event.getButton() == MouseEvent.BUTTON3) {
		isSecondaryPressed = true;
	}
}
 
Example 11
Project: incubator-netbeans   File: SelectAction.java   View Source Code Vote up 5 votes
public State mousePressed (Widget widget, WidgetMouseEvent event) {
    if (isLocked()) {
        return State.createLocked(widget, this);
    }
    
    Point localLocation = event.getPoint();
    
    if (event.getButton() == MouseEvent.BUTTON1 || event.getButton() == MouseEvent.BUTTON2) {
        invertSelection = (event.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0;
        
        if (provider.isSelectionAllowed(widget, localLocation, invertSelection)) {
            aiming = provider.isAimingAllowed(widget, localLocation, invertSelection);
            if (aiming) {
                updateState(widget, localLocation);
                return State.createLocked(widget, this);
            } else {
                provider.select(widget, localLocation, invertSelection);
                return State.CHAIN_ONLY;
            }
        }
    } else if (trapRightClick && event.getButton() == MouseEvent.BUTTON3) {
        provider.select(widget, localLocation, false);
        return State.CHAIN_ONLY;
    }
    
    return State.REJECTED;
}
 
Example 12
Project: incubator-netbeans   File: VMDNodeWidget.java   View Source Code Vote up 5 votes
public State mousePressed (Widget widget, WidgetMouseEvent event) {
    if (event.getButton () == MouseEvent.BUTTON1 || event.getButton () == MouseEvent.BUTTON2) {
        stateModel.toggleBooleanState ();
        return State.CONSUMED;
    }
    return State.REJECTED;
}
 
Example 13
Project: incubator-netbeans   File: SlideGestureRecognizer.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent e) {
    // no operation
    if( e.getButton() == MouseEvent.BUTTON2 ) {
        slideBar.userMiddleClickedSlidingButton(e.getComponent());
    }
}
 
Example 14
Project: incubator-netbeans   File: Utils.java   View Source Code Vote up 5 votes
@Override
public State mousePressed(Widget widget, WidgetMouseEvent event) {
    if (event.getClickCount() == 1) {
        if (event.getButton() == MouseEvent.BUTTON1 || event.getButton() == MouseEvent.BUTTON2) {
            addNode("node" + nodeCounter++).setPreferredLocation(widget.convertLocalToScene(event.getPoint()));
            return State.CONSUMED;
        }
    }
    return State.REJECTED;
}
 
Example 15
Project: marathonv5   File: EventQueueDevice.java   View Source Code Vote up 5 votes
private void storeMouseDown(int button) {
    if (button == MouseEvent.BUTTON1) {
        button1Pressed = true;
    }
    if (button == MouseEvent.BUTTON2) {
        button2Pressed = true;
    }
    if (button == MouseEvent.BUTTON3) {
        button3Pressed = true;
    }
}
 
Example 16
Project: marathonv5   File: EventQueueDevice.java   View Source Code Vote up 5 votes
public int getButtons() {
    if (button1Pressed) {
        return MouseEvent.BUTTON1;
    }
    if (button2Pressed) {
        return MouseEvent.BUTTON2;
    }
    if (button3Pressed) {
        return MouseEvent.BUTTON3;
    }
    return 0;
}
 
Example 17
Project: freecol   File: CanvasMouseListener.java   View Source Code Vote up 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 18
Project: sumo   File: EventHelper.java   View Source Code Vote up 5 votes
public static MouseButton getMouseButton(MouseEvent me) {
	switch(me.getButton()) {
		case MouseEvent.BUTTON1:
			return MouseButton.LEFT;
		case MouseEvent.BUTTON2:
			return MouseButton.MIDDLE;
		case MouseEvent.BUTTON3:
			return MouseButton.RIGHT;
		case MouseEvent.MOUSE_WHEEL:
			return MouseButton.WHEEL;
		default:
			return MouseButton.LEFT;
	}
}
 
Example 19
Project: YtQueue   File: YtQueueFrame.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent e) {
    if (e.isControlDown() || e.isShiftDown() && e.getButton() != MouseEvent.BUTTON3) {
        VideoViewer viewer = VideoViewer.INSTANCE;
        if (viewer.PLAYER.isPlaying()) {
            Dimension dim = viewer.PLAYER.getVideoDimension();
            if (e.getButton() == MouseEvent.BUTTON1) {
                updateVisibility(false);
            } else {
                updateVisibility(true);
            }
            YtQueueFrame frame = YtQueueFrame.INSTANCE;
            int x = frame.getX(), y = frame.getY(), w = frame.getWidth(), h = frame.getHeight();
            double simillar = dim.width / (double) w;
            if (e.isShiftDown()) {
                simillar = 1;
            }
            dim.width = (int) (dim.width / simillar);
            dim.height = (int) (dim.height / simillar) +
                         (e.getButton() != MouseEvent.BUTTON2 ? 0 : SearchPanel.INSTANCE.getHeight() +
                                                                    VideoViewer.INSTANCE.MANAGER.getHeight());
            frame.setBounds(x + w - dim.width, y + h - dim.height, dim.width, dim.height);
        }
    }
    if (e.getClickCount() == 2) {
        if (e.getButton() == MouseEvent.BUTTON1) {
            updateVisibility(!SearchPanel.INSTANCE.isVisible());
        } else if (e.getButton() == MouseEvent.BUTTON2) {
            close();
        }
    }
}
 
Example 20
Project: Mafia   File: MouseInput.java   View Source Code Vote up 5 votes
@Override
public void mouseReleased(MouseEvent event) {
	if(event.getButton() == MouseEvent.BUTTON1) {
		isPrimaryPressed = false;
		wasPrimaryClicked = true;
		
	} else if(event.getButton() == MouseEvent.BUTTON2) {
		isMiddlePressed = false;
		wasMiddleClicked = true;
		
	} else if(event.getButton() == MouseEvent.BUTTON3) {
		isSecondaryPressed = false;
		wasSecondaryClicked = true;
	}
}