Java Code Examples for java.awt.event.MouseWheelEvent#getModifiersEx()

The following examples show how to use java.awt.event.MouseWheelEvent#getModifiersEx() . 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 check out the related API usage on the sidebar.
Example 1
Source File: TabPagerMouseWheelListener.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
	TabPreviewPainter tpp = TabPreviewUtilities
			.getTabPreviewPainter(this.tabbedPane);
	if (tpp == null)
		return;

	if (((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0)
			&& e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
		int amount = e.getWheelRotation();
		TabPagerManager te = TabPagerManager.getPager();
		if (te.isVisible()) {
			if (amount > 0) {
				if (this.tabbedPane != null)
					te.page(this.tabbedPane, true);
				else
					te.page(true);
			} else {
				if (this.tabbedPane != null)
					te.page(this.tabbedPane, false);
				else
					te.page(false);
			}
		}
	}
}
 
Example 2
Source File: MouseEventUI.java    From darklaf with MIT License 5 votes vote down vote up
private MouseWheelEvent createMouseWheelEvent(final MouseWheelEvent mouseWheelEvent, final Point point,
                                              final Component target) {
    return new MouseWheelEvent(target,
                               mouseWheelEvent.getID(),
                               mouseWheelEvent.getWhen(),
                               mouseWheelEvent.getModifiersEx(),
                               point.x,
                               point.y,
                               mouseWheelEvent.getClickCount(),
                               mouseWheelEvent.isPopupTrigger(),
                               mouseWheelEvent.getScrollType(),
                               mouseWheelEvent.getScrollAmount(),
                               mouseWheelEvent.getWheelRotation());
}
 
Example 3
Source File: UIUtilities.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Clones a {@link MouseEvent}.
 *
 * @param event The event to clone.
 * @return The new {@link MouseEvent}.
 */
public static final MouseEvent cloneMouseEvent(MouseEvent event) {
    if (event instanceof MouseWheelEvent) {
        MouseWheelEvent old = (MouseWheelEvent) event;
        return new MouseWheelEvent((Component) old.getSource(), old.getID(), System.currentTimeMillis(), old.getModifiersEx(), old.getX(), old.getY(), old.getClickCount(), old.isPopupTrigger(), old.getScrollType(), old.getScrollAmount(), old.getWheelRotation());
    }
    return new MouseEvent((Component) event.getSource(), event.getID(), System.currentTimeMillis(), event.getModifiersEx(), event.getX(), event.getY(), event.getClickCount(), event.isPopupTrigger());
}
 
Example 4
Source File: UIUtilities.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Clones a {@link MouseEvent}.
 *
 * @param event       The event to clone.
 * @param refreshTime Pass in {@code true} to generate a new time stamp.
 * @return The new {@link MouseEvent}.
 */
public static final MouseEvent cloneMouseEvent(MouseEvent event, boolean refreshTime) {
    if (event instanceof MouseWheelEvent) {
        MouseWheelEvent old = (MouseWheelEvent) event;
        return new MouseWheelEvent((Component) old.getSource(), old.getID(), refreshTime ? System.currentTimeMillis() : event.getWhen(), old.getModifiersEx(), old.getX(), old.getY(), old.getClickCount(), old.isPopupTrigger(), old.getScrollType(), old.getScrollAmount(), old.getWheelRotation());
    }
    return new MouseEvent((Component) event.getSource(), event.getID(), refreshTime ? System.currentTimeMillis() : event.getWhen(), event.getModifiersEx(), event.getX(), event.getY(), event.getClickCount(), event.isPopupTrigger());
}
 
Example 5
Source File: PDControlScrollPane.java    From Decoder-Improved with GNU General Public License v3.0 4 votes vote down vote up
private MouseWheelEvent cloneEvent(MouseWheelEvent e) {
    return new MouseWheelEvent(getParentScrollPane(), e.getID(), e
            .getWhen(), e.getModifiersEx(), 1, 1, e
            .getClickCount(), false, e.getScrollType(), e
            .getScrollAmount(), e.getWheelRotation());
}
 
Example 6
Source File: SwingTerminal.java    From jexer with MIT License 4 votes vote down vote up
/**
 * Pass mouse events into the event queue.
 *
 * @param mouse mouse event received
 */
public void mouseWheelMoved(final MouseWheelEvent mouse) {
    int modifiers = mouse.getModifiersEx();
    boolean eventMouse1 = false;
    boolean eventMouse2 = false;
    boolean eventMouse3 = false;
    boolean mouseWheelUp = false;
    boolean mouseWheelDown = false;
    if ((modifiers & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
        eventMouse1 = true;
    }
    if ((modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0) {
        eventMouse2 = true;
    }
    if ((modifiers & MouseEvent.BUTTON3_DOWN_MASK) != 0) {
        eventMouse3 = true;
    }
    mouse1 = eventMouse1;
    mouse2 = eventMouse2;
    mouse3 = eventMouse3;
    int x = textColumn(mouse.getX());
    int y = textRow(mouse.getY());
    if (mouse.getWheelRotation() > 0) {
        mouseWheelDown = true;
    }
    if (mouse.getWheelRotation() < 0) {
        mouseWheelUp = true;
    }

    TMouseEvent mouseEvent = new TMouseEvent(TMouseEvent.Type.MOUSE_DOWN,
        x, y, x, y, mouse1, mouse2, mouse3, mouseWheelUp, mouseWheelDown);

    synchronized (eventQueue) {
        eventQueue.add(mouseEvent);
        resetBlinkTimer();
    }
    if (listener != null) {
        synchronized (listener) {
            listener.notifyAll();
        }
    }
}
 
Example 7
Source File: UIUtilities.java    From gcs with Mozilla Public License 2.0 3 votes vote down vote up
/**
 * Clones a {@link MouseEvent}.
 *
 * @param event       The event to clone.
 * @param source      Pass in a new source.
 * @param where       Pass in a new location.
 * @param refreshTime Pass in {@code true} to generate a new time stamp.
 * @return The new {@link MouseEvent}.
 */
public static final MouseEvent cloneMouseEvent(MouseEvent event, Component source, Point where, boolean refreshTime) {
    if (event instanceof MouseWheelEvent) {
        MouseWheelEvent old = (MouseWheelEvent) event;
        return new MouseWheelEvent(source, old.getID(), refreshTime ? System.currentTimeMillis() : event.getWhen(), old.getModifiersEx(), where.x, where.y, old.getClickCount(), old.isPopupTrigger(), old.getScrollType(), old.getScrollAmount(), old.getWheelRotation());
    }
    return new MouseEvent(source, event.getID(), refreshTime ? System.currentTimeMillis() : event.getWhen(), event.getModifiersEx(), where.x, where.y, event.getClickCount(), event.isPopupTrigger());
}