Java Code Examples for java.awt.event.InputEvent.BUTTON3_MASK

The following are Jave code examples for showing how to use BUTTON3_MASK of the java.awt.event.InputEvent 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: marathonv5   File: RobotDevice.java   View Source Code Vote up 7 votes
@Override public void click(Component component, Buttons button, int clickCount, int xoffset, int yoffset) {
    ensureVisible(component, new Rectangle(xoffset, yoffset, 50, 50));
    int b = InputEvent.BUTTON1_MASK;
    if (button.getButton() == 0) {
        b = InputEvent.BUTTON1_MASK;
    } else if (button.getButton() == 1) {
        b = InputEvent.BUTTON2_MASK;
    } else if (button.getButton() == 2) {
        b = InputEvent.BUTTON3_MASK;
    }
    Point compLocation = component.getLocationOnScreen();
    int x = compLocation.x + xoffset;
    int y = compLocation.y + yoffset;
    robotXmouseMove(x, y);
    for (int i = 0; i < clickCount; i++) {
        robotXmousePress(b);
        robotXmouseRelease(b);
    }
}
 
Example 2
Project: ripme   File: QueueMenuMouseListener.java   View Source Code Vote up 6 votes
@Override
public void mouseClicked(MouseEvent e) {
    if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
        if (!(e.getSource() instanceof JList)) {
            return;
        }

        queueList = (JList) e.getSource();
        queueListModel = (DefaultListModel) queueList.getModel();
        queueList.requestFocus();

        int nx = e.getX();

        if (nx > 500) {
            nx = nx - popup.getSize().width;
        }
        popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height);
    }
}
 
Example 3
Project: openjdk-jdk10   File: Util.java   View Source Code Vote up 6 votes
/**
 * Drags from one point to another with the specified mouse button pressed.
 *
 * @param robot a robot to use for moving the mouse, etc.
 * @param startPoint a start point of the drag
 * @param endPoint an end point of the drag
 * @param button one of {@code InputEvent.BUTTON1_MASK},
 *     {@code InputEvent.BUTTON2_MASK}, {@code InputEvent.BUTTON3_MASK}
 *
 * @throws IllegalArgumentException if {@code button} is not one of
 *     {@code InputEvent.BUTTON1_MASK}, {@code InputEvent.BUTTON2_MASK},
 *     {@code InputEvent.BUTTON3_MASK}
 */
public static void drag(Robot robot, Point startPoint, Point endPoint, int button) {
    if (!(button == InputEvent.BUTTON1_MASK || button == InputEvent.BUTTON2_MASK
            || button == InputEvent.BUTTON3_MASK))
    {
        throw new IllegalArgumentException("invalid mouse button");
    }

    robot.mouseMove(startPoint.x, startPoint.y);
    robot.mousePress(button);
    try {
        mouseMove(robot, startPoint, endPoint);
    } finally {
        robot.mouseRelease(button);
    }
}
 
Example 4
Project: openjdk-jdk10   File: DragSourceDragEvent.java   View Source Code Vote up 6 votes
/**
 * Sets new modifiers by the old ones.
 * The mouse modifiers have higher priority than overlaying key
 * modifiers.
 */
@SuppressWarnings("deprecation")
private void setNewModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
    }
}
 
Example 5
Project: OpenJSharp   File: DragSourceDragEvent.java   View Source Code Vote up 6 votes
/**
 * Sets old modifiers by the new ones.
 */
private void setOldModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_MASK;
    }
}
 
Example 6
Project: OpenJSharp   File: Robot.java   View Source Code Vote up 6 votes
private static synchronized void initLegalButtonMask() {
    if (LEGAL_BUTTON_MASK != 0) return;

    int tmpMask = 0;
    if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
        if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
            final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
            for (int i = 0; i < buttonsNumber; i++){
                tmpMask |= InputEvent.getMaskForButton(i+1);
            }
        }
    }
    tmpMask |= InputEvent.BUTTON1_MASK|
        InputEvent.BUTTON2_MASK|
        InputEvent.BUTTON3_MASK|
        InputEvent.BUTTON1_DOWN_MASK|
        InputEvent.BUTTON2_DOWN_MASK|
        InputEvent.BUTTON3_DOWN_MASK;
    LEGAL_BUTTON_MASK = tmpMask;
}
 
Example 7
Project: jdk8u-jdk   File: DragSourceDragEvent.java   View Source Code Vote up 6 votes
/**
 * Sets new modifiers by the old ones.
 * The mouse modifiers have higher priority than overlaying key
 * modifiers.
 */
private void setNewModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
    }
}
 
Example 8
Project: jdk8u-jdk   File: DragSourceDragEvent.java   View Source Code Vote up 6 votes
/**
 * Sets old modifiers by the new ones.
 */
private void setOldModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_MASK;
    }
}
 
Example 9
Project: jdk8u-jdk   File: Util.java   View Source Code Vote up 6 votes
/**
 * Drags from one point to another with the specified mouse button pressed.
 *
 * @param robot a robot to use for moving the mouse, etc.
 * @param startPoint a start point of the drag
 * @param endPoint an end point of the drag
 * @param button one of {@code InputEvent.BUTTON1_MASK},
 *     {@code InputEvent.BUTTON2_MASK}, {@code InputEvent.BUTTON3_MASK}
 *
 * @throws IllegalArgumentException if {@code button} is not one of
 *     {@code InputEvent.BUTTON1_MASK}, {@code InputEvent.BUTTON2_MASK},
 *     {@code InputEvent.BUTTON3_MASK}
 */
public static void drag(Robot robot, Point startPoint, Point endPoint, int button) {
    if (!(button == InputEvent.BUTTON1_MASK || button == InputEvent.BUTTON2_MASK
            || button == InputEvent.BUTTON3_MASK))
    {
        throw new IllegalArgumentException("invalid mouse button");
    }

    robot.mouseMove(startPoint.x, startPoint.y);
    robot.mousePress(button);
    try {
        mouseMove(robot, startPoint, endPoint);
    } finally {
        robot.mouseRelease(button);
    }
}
 
Example 10
Project: alevin-svn2   File: MyEditingPopupGraphMousePlugin.java   View Source Code Vote up 5 votes
public MyEditingPopupGraphMousePlugin(final LayerViewer<V, E> vv, Scenario scenario) {
	super(InputEvent.BUTTON3_MASK, new Factory<V>() {
		private final int layer = vv.getLayer().getLayer();

		@SuppressWarnings("unchecked")
		@Override
		public V create() {
			if (layer > 0)
				return (V) new VirtualNode(layer);
			else
				return (V) new SubstrateNode();
		}
	}, new Factory<E>() {
		private final int layer = vv.getLayer().getLayer();

		@SuppressWarnings("unchecked")
		@Override
		public E create() {
			if (layer > 0)
				return (E) new VirtualLink(layer);
			else
				return (E) new SubstrateLink();
		}
	});

	this.scenario = scenario;
	this.vv = vv;
}
 
Example 11
Project: ripme   File: ContextMenuMouseListener.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent e) {
    if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
        if (!(e.getSource() instanceof JTextComponent)) {
            return;
        }

        textComponent = (JTextComponent) e.getSource();
        textComponent.requestFocus();

        boolean enabled = textComponent.isEnabled();
        boolean editable = textComponent.isEditable();
        boolean nonempty = !(textComponent.getText() == null || textComponent.getText().equals(""));
        boolean marked = textComponent.getSelectedText() != null;

        boolean pasteAvailable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).isDataFlavorSupported(DataFlavor.stringFlavor);

        undoAction.setEnabled(enabled && editable && (lastActionSelected == Actions.CUT || lastActionSelected == Actions.PASTE));
        cutAction.setEnabled(enabled && editable && marked);
        copyAction.setEnabled(enabled && marked);
        pasteAction.setEnabled(enabled && editable && pasteAvailable);
        selectAllAction.setEnabled(enabled && nonempty);

        int nx = e.getX();

        if (nx > 500) {
            nx = nx - popup.getSize().width;
        }

        popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height);
    }
}
 
Example 12
Project: incubator-netbeans   File: ProfilingPointsWindowUI.java   View Source Code Vote up 5 votes
public void mousePressed(MouseEvent e) {
    if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
        int clickedRow = profilingPointsTable.rowAtPoint(e.getPoint());

        if (clickedRow != -1) {
            int[] selectedRows = profilingPointsTable.getSelectedRows();

            if (selectedRows.length == 0) {
                profilingPointsTable.setRowSelectionInterval(clickedRow, clickedRow);
            } else {
                boolean changeSelection = true;

                for (int selectedRow : selectedRows) {
                    if (selectedRow == clickedRow) {
                        changeSelection = false;
                    }
                }

                if (changeSelection) {
                    profilingPointsTable.setRowSelectionInterval(clickedRow, clickedRow);
                }
            }
        }
    }

    dispatchResultsRendererEvent(e);
}
 
Example 13
Project: rapidminer   File: JEditTextArea.java   View Source Code Vote up 5 votes
@Override
public void mousePressed(MouseEvent evt) {
	requestFocus();

	// Focus events not fired sometimes?
	setCaretVisible(true);
	focusedComponent = JEditTextArea.this;

	if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0 && popup != null) {
		popup.show(painter, evt.getX(), evt.getY());
		return;
	}

	int line = yToLine(evt.getY());
	int offset = xToOffset(line, evt.getX());
	int dot = getLineStartOffset(line) + offset;

	switch (evt.getClickCount()) {
		case 1:
			doSingleClick(evt, line, offset, dot);
			break;
		case 2:
			// It uses the bracket matching stuff, so
			// it can throw a BLE
			try {
				doDoubleClick(evt, line, offset, dot);
			} catch (BadLocationException bl) {
				bl.printStackTrace();
			}
			break;
		case 3:
			doTripleClick(evt, line, offset, dot);
			break;
	}
}
 
Example 14
Project: marathonv5   File: EventQueueDevice.java   View Source Code Vote up 5 votes
private void dispatchMouseEvent(Component component, boolean popupTrigger, int clickCount, int buttons, int x, int y) {
    ensureVisible(component, new Rectangle(x, y, 50, 50));
    EventQueueWait.call_noexc(component, "requestFocusInWindow");
    int modifierEx = deviceState.getModifierEx();
    if (component != deviceState.getComponent()) {
        if (deviceState.getComponent() != null) {
            dispatchEvent(new MouseEvent(deviceState.getComponent(), MouseEvent.MOUSE_EXITED, System.currentTimeMillis(),
                    modifierEx, deviceState.x, deviceState.y, 0, popupTrigger, buttons));
        }
        dispatchEvent(new MouseEvent(component, MouseEvent.MOUSE_ENTERED, System.currentTimeMillis(), modifierEx, x, y, 0,
                popupTrigger, buttons));
    }
    for (int n = 1; n <= clickCount; n++) {
        int buttonMask = InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON1_MASK;
        if (buttons == 3) {
            buttonMask = InputEvent.BUTTON3_DOWN_MASK | InputEvent.BUTTON3_MASK;
        }
        dispatchEvent(new MouseEvent(component, MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), modifierEx | buttonMask,
                x, y, n, popupTrigger, buttons));
        buttonMask = InputEvent.BUTTON1_MASK;
        if (buttons == 3) {
            buttonMask = InputEvent.BUTTON3_MASK;
        }
        dispatchEvent(new MouseEvent(component, MouseEvent.MOUSE_RELEASED, System.currentTimeMillis(), modifierEx | buttonMask,
                x, y, n, false, buttons));
        dispatchEvent(new MouseEvent(component, MouseEvent.MOUSE_CLICKED, System.currentTimeMillis(), modifierEx | buttonMask,
                x, y, n, false, buttons));
    }
}
 
Example 15
Project: openjdk-jdk10   File: NormalBoundsTest.java   View Source Code Vote up 5 votes
private static void drag(Robot r, Point startPt, Point endPt, int button) {
    if (!(button == InputEvent.BUTTON1_MASK
            || button == InputEvent.BUTTON2_MASK
            || button == InputEvent.BUTTON3_MASK)) {
        throw new IllegalArgumentException("invalid mouse button");
    }

    r.mouseMove(startPt.x, startPt.y);
    r.mousePress(button);
    try {
        mouseMove(r, startPt, endPt);
    } finally {
        r.mouseRelease(button);
    }
}
 
Example 16
Project: openjdk-jdk10   File: EventDispatcher.java   View Source Code Vote up 5 votes
/**
 * Returns a mouse button string representation. Used to print trace.
 *
 * @param button Mouse button ({@code InputEvent.BUTTON1/2/3_MASK}
 * value).
 * @return InputEvent field name.
 */
public static String getMouseButtonDescription(int button) {
    String result;
    if ((button & InputEvent.BUTTON1_MASK) != 0) {
        result = "BUTTON1";
    } else if ((button & InputEvent.BUTTON2_MASK) != 0) {
        result = "BUTTON2";
    } else if ((button & InputEvent.BUTTON3_MASK) != 0) {
        result = "BUTTON3";
    } else {
        result = "UNKNOWN_BUTTON";
    }
    return result;
}
 
Example 17
Project: OpenDA   File: EditablePlot.java   View Source Code Vote up 4 votes
public void mousePressed(MouseEvent event) {
    if ((event.getModifiers() & InputEvent.BUTTON3_MASK)!= 0) {
        EditablePlot.this._editStart(event.getX(), event.getY());
    }
}
 
Example 18
Project: OpenDA   File: EditablePlot.java   View Source Code Vote up 4 votes
public void mouseReleased(MouseEvent event) {
    if ((event.getModifiers() & InputEvent.BUTTON3_MASK)!= 0) {
        EditablePlot.this._edit(event.getX(), event.getY());
    }
}
 
Example 19
Project: openjdk-jdk10   File: bug7146377.java   View Source Code Vote up 4 votes
private static boolean oldIsRightMouseButton(MouseEvent e) {
    return ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK);
}
 
Example 20
Project: openjdk-jdk10   File: Operator.java   View Source Code Vote up 2 votes
/**
 * Returns mask of mouse button which used to popup expanding.
 * (InputEvent.BUTTON3_MASK)
 *
 * @return {@code InputEvent.BUTTON*_MASK} field value
 */
public static int getPopupMouseButton() {
    return InputEvent.BUTTON3_MASK;
}