Java Code Examples for javax.swing.SwingUtilities#isMiddleMouseButton()
The following examples show how to use
javax.swing.SwingUtilities#isMiddleMouseButton() .
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: SeaGlassScrollBarUI.java From seaglass with Apache License 2.0 | 6 votes |
/** * If the mouse is pressed above the "thumb" component then reduce the * scrollbars value by one page ("page up"), otherwise increase it by * one page. If there is no thumb then page up if the mouse is in the * upper half of the track. */ public void mousePressed(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e) || (!getSupportsAbsolutePositioning() && SwingUtilities.isMiddleMouseButton(e))) return; if (!scrollbar.isEnabled()) return; currentMouseX = e.getX(); currentMouseY = e.getY(); isMouseButtonDown = false; // Clicked in the Thumb area? if (getThumbBounds().contains(currentMouseX, currentMouseY)) { isMouseButtonDown = true; scrollbar.repaint(); } }
Example 2
Source File: ScreenMarkerMouseListener.java From plugins with GNU General Public License v3.0 | 6 votes |
@Override public MouseEvent mouseReleased(MouseEvent event) { if (SwingUtilities.isMiddleMouseButton(event)) { return event; } if (SwingUtilities.isLeftMouseButton(event) && plugin.isCreatingScreenMarker()) { /* Set the creation panel as "ready" (because the marker area as been drawn) */ plugin.completeSelection(); } event.consume(); return event; }
Example 3
Source File: HyperlinkOperation.java From netbeans with Apache License 2.0 | 6 votes |
public void mouseClicked(MouseEvent e) { if(e.isConsumed()) return; boolean activate = false; HyperlinkType type = getHyperlinkType(e); if ( type != null ) { activate = !e.isPopupTrigger() && e.getClickCount() == 1 && SwingUtilities.isLeftMouseButton(e); } else if ( Utilities.isWindows() && e.getClickCount() == 1 && SwingUtilities.isMiddleMouseButton(e) ) { activate = true; type = HyperlinkType.GO_TO_DECLARATION; } if ( activate ) { int position = component.viewToModel(e.getPoint()); if (position < 0) { return ; } performAction(position, type); } }
Example 4
Source File: TabTitleEditListener.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
@Override public void mouseClicked(MouseEvent e) { if (tabbedPane.getSelectedIndex() != -1) { Rectangle rect = tabbedPane.getUI().getTabBounds(tabbedPane, tabbedPane.getSelectedIndex()); if (rect.contains(e.getPoint())) { if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { if (checkIndexContains()) { startEditing(); } } else if (SwingUtilities.isMiddleMouseButton(e)) { if (onMiddleClickAction != null) { onMiddleClickAction.actionPerformed(null); } } } else { renameTabTitle(); } } }
Example 5
Source File: MapRenderer.java From open-ig with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void mousePressed(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { drag = true; lastX = e.getX(); lastY = e.getY(); } else if (SwingUtilities.isMiddleMouseButton(e)) { offsetX = 0; offsetY = 0; if (e.isControlDown()) { scale = 1; } repaint(); } }
Example 6
Source File: ScreenMarkerMouseListener.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Override public MouseEvent mouseReleased(MouseEvent event) { if (SwingUtilities.isMiddleMouseButton(event)) { return event; } if (SwingUtilities.isLeftMouseButton(event) && plugin.isCreatingScreenMarker()) { /* Set the creation panel as "ready" (because the marker area as been drawn) */ plugin.completeSelection(); } event.consume(); return event; }
Example 7
Source File: ScreenMarkerMouseListener.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Override public MouseEvent mouseClicked(MouseEvent event) { if (SwingUtilities.isMiddleMouseButton(event)) { return event; } event.consume(); return event; }
Example 8
Source File: PressOrClickMouseAdapter.java From Shuffle-Move with GNU General Public License v3.0 | 5 votes |
@Override public void mouseClicked(MouseEvent e) { if (ignoreClick()) { return; } if (SwingUtilities.isRightMouseButton(e) | SwingUtilities.isLeftMouseButton(e) && e.isControlDown()) { onRight(e); } else if (SwingUtilities.isLeftMouseButton(e)) { onLeft(e); } else if (SwingUtilities.isMiddleMouseButton(e)) { onMiddle(e); } }
Example 9
Source File: ScreenMarkerMouseListener.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@Override public MouseEvent mousePressed(MouseEvent event) { if (SwingUtilities.isMiddleMouseButton(event)) { return event; } if (SwingUtilities.isLeftMouseButton(event)) { final Rectangle bounds = plugin.getSelectedWidgetBounds(); if (bounds != null) { plugin.startCreation(bounds.getLocation(), bounds.getSize()); } else { plugin.startCreation(event.getPoint()); } } else if (plugin.isCreatingScreenMarker()) { plugin.finishCreation(true); } event.consume(); return event; }
Example 10
Source File: ScreenMarkerMouseListener.java From plugins with GNU General Public License v3.0 | 5 votes |
@Override public MouseEvent mouseClicked(MouseEvent event) { if (SwingUtilities.isMiddleMouseButton(event)) { return event; } event.consume(); return event; }
Example 11
Source File: bug7088744.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void processEvent(int eventType, MouseEvent e) { if (eventCount >= BUTTON_EVENTS_SEQUENCE.length) { throw new RuntimeException("Unexpected event " + e); } int[] arr = BUTTON_EVENTS_SEQUENCE[eventCount]; if (arr[0] != eventType) { throw new RuntimeException("Unexpected eventType " + eventType + "on step " + eventCount); } boolean result; switch (arr[1]) { case 1: result = SwingUtilities.isLeftMouseButton(e); break; case 2: result = SwingUtilities.isMiddleMouseButton(e); break; case 3: result = SwingUtilities.isRightMouseButton(e); break; default: throw new RuntimeException("Incorrect arr[1] on step " + eventCount); } if (!result) { throw new RuntimeException("Test failed on step " + eventCount); } eventCount++; }
Example 12
Source File: ProfilerTabbedPane.java From visualvm with GNU General Public License v2.0 | 5 votes |
protected void processMouseEvent(MouseEvent e) { int index = indexAtLocation(e.getX(), e.getY()); if (index != -1) { if (e.isPopupTrigger()) { // Show popup menu for the clicked tab final MouseEvent _e = e; final int _index = index; final Component _component = getComponentAt(index); SwingUtilities.invokeLater(new Runnable() { public void run() { showPopupMenu(_index, _component, _e); }; }); e.consume(); return; } else if (e.getID() == MouseEvent.MOUSE_CLICKED && SwingUtilities.isMiddleMouseButton(e)) { // Close tab using middle button click if (isClosableAt(index)) closeTab(getComponentAt(index)); e.consume(); return; } else if (e.getID() == MouseEvent.MOUSE_PRESSED && !SwingUtilities.isLeftMouseButton(e)) { // Do not switch tabs using middle or right mouse button e.consume(); return; } } super.processMouseEvent(e); }
Example 13
Source File: bug7088744.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void processEvent(int eventType, MouseEvent e) { if (eventCount >= BUTTON_EVENTS_SEQUENCE.length) { throw new RuntimeException("Unexpected event " + e); } int[] arr = BUTTON_EVENTS_SEQUENCE[eventCount]; if (arr[0] != eventType) { throw new RuntimeException("Unexpected eventType " + eventType + "on step " + eventCount); } boolean result; switch (arr[1]) { case 1: result = SwingUtilities.isLeftMouseButton(e); break; case 2: result = SwingUtilities.isMiddleMouseButton(e); break; case 3: result = SwingUtilities.isRightMouseButton(e); break; default: throw new RuntimeException("Incorrect arr[1] on step " + eventCount); } if (!result) { throw new RuntimeException("Test failed on step " + eventCount); } eventCount++; }
Example 14
Source File: ScreenMarkerMouseListener.java From plugins with GNU General Public License v3.0 | 5 votes |
@Override public MouseEvent mousePressed(MouseEvent event) { if (SwingUtilities.isMiddleMouseButton(event)) { return event; } if (SwingUtilities.isLeftMouseButton(event)) { final Rectangle bounds = plugin.getSelectedWidgetBounds(); if (bounds != null) { plugin.startCreation(bounds.getLocation(), bounds.getSize()); } else { plugin.startCreation(event.getPoint()); } } else if (plugin.isCreatingScreenMarker()) { plugin.finishCreation(true); } event.consume(); return event; }
Example 15
Source File: CMousePressedHandler.java From binnavi with Apache License 2.0 | 4 votes |
public static IMouseStateChange handleMousePressed(final CStateFactory<?, ?> factory, final IMouseState defaultState, final AbstractZyGraph<?, ?> graph, final MouseEvent event) { final double x = graph.getEditMode().translateX(event.getX()); final double y = graph.getEditMode().translateY(event.getY()); final HitInfo hitInfo = graph.getGraph().getHitInfo(x, y); if (hitInfo.hasHitNodes()) { final Node n = hitInfo.getHitNode(); if (SwingUtilities.isLeftMouseButton(event) && !event.isAltDown()) { return new CStateChange(factory.createNodePressedLeftState(n, event), true); } else if (SwingUtilities.isRightMouseButton(event)) { return new CStateChange(factory.createNodePressedRightState(n, event), true); } else if (SwingUtilities.isMiddleMouseButton(event) || (event.isAltDown() && SwingUtilities.isLeftMouseButton(event))) { return new CStateChange(factory.createNodePressedMiddleState(n, event), false); } else { // A button was pressed that does not have any special functionality. return new CStateChange(defaultState, true); } } else if (hitInfo.hasHitNodeLabels()) { throw new IllegalStateException("yFiles Labels are not in use..."); } else if (hitInfo.hasHitEdges()) { final Edge edge = hitInfo.getHitEdge(); if (SwingUtilities.isLeftMouseButton(event)) { return new CStateChange(factory.createEdgePressedLeftState(edge, event), true); } else if (SwingUtilities.isRightMouseButton(event)) { return new CStateChange(factory.createEdgePressedRightState(edge, event), true); } else { return new CStateChange(defaultState, true); } } else if (hitInfo.hasHitEdgeLabels()) { // final EdgeLabel label = hitInfo.getHitEdgeLabel(); // // if (SwingUtilities.isLeftMouseButton(event)) // { // return new CStateChange(factory.createEdgeLabelPressedLeftState(label, event), true); // } // else if (SwingUtilities.isRightMouseButton(event)) // { // return new CStateChange(factory.createEdgeLabelPressedRightState(label, event), true); // } // else // { return new CStateChange(defaultState, true); // } } else if (hitInfo.hasHitBends()) { final Bend bend = hitInfo.getHitBend(); if (SwingUtilities.isLeftMouseButton(event)) { return new CStateChange(factory.createBendPressedLeftState(bend, event), true); } else { return new CStateChange(defaultState, true); } } else if (hitInfo.hasHitPorts()) { return new CStateChange(factory.createDefaultState(), true); } else { if (SwingUtilities.isLeftMouseButton(event)) { return new CStateChange(factory.createBackgroundPressedLeftState(event), true); } else if (SwingUtilities.isRightMouseButton(event)) { return new CStateChange(factory.createBackgroundPressedRightState(event), true); } return new CStateChange(factory.createDefaultState(), true); } }
Example 16
Source File: CNodeEditState.java From binnavi with Apache License 2.0 | 4 votes |
@Override public IMouseStateChange mousePressed(final MouseEvent event, final AbstractZyGraph<?, ?> graph) { final double x = graph.getEditMode().translateX(event.getX()); final double y = graph.getEditMode().translateY(event.getY()); final HitInfo hitInfo = graph.getGraph().getHitInfo(x, y); if (hitInfo.hasHitNodes()) { final Node n = hitInfo.getHitNode(); if (SwingUtilities.isLeftMouseButton(event) && !event.isAltDown()) { if (n == m_node) { if (!m_isDragging) { // Change caret CEditNodeHelper.setCaretStart(graph, n, event); } else { m_isDragging = false; } return new CStateChange(this, false); } else { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createNodePressedLeftState(n, event), true); } } else if (SwingUtilities.isRightMouseButton(event)) { if (n == m_node) { // Do nothing return new CStateChange(this, false); } else { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createNodePressedRightState(n, event), true); } } else if (SwingUtilities.isMiddleMouseButton(event) || (event.isAltDown() && SwingUtilities.isLeftMouseButton(event))) { if (n == m_node) { // m_factory.createNodeEditExitState(m_node, event); if (!m_isDragging) { // Change caret CEditNodeHelper.setCaretStart(graph, n, event); } else { m_isDragging = false; } return new CStateChange(this, false); } else { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createNodePressedMiddleState(n, event), true); } } else { // A button was pressed that does not have any special functionality. return new CStateChange(this, false); } } else if (hitInfo.hasHitNodeLabels()) { throw new IllegalStateException(); } else if (hitInfo.hasHitEdges()) { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdge(), event), true); } else if (hitInfo.hasHitEdgeLabels()) { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdgeLabel() .getEdge(), event), true); } else if (hitInfo.hasHitBends()) { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createBendPressedLeftState(hitInfo.getHitBend(), event), true); } else if (hitInfo.hasHitPorts()) { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createDefaultState(), true); } else { // User left-pressed the background. m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createBackgroundPressedLeftState(event), true); } }
Example 17
Source File: CNodeEditState.java From binnavi with Apache License 2.0 | 4 votes |
@Override public IMouseStateChange mouseReleased(final MouseEvent event, final AbstractZyGraph<?, ?> graph) { final double x = graph.getEditMode().translateX(event.getX()); final double y = graph.getEditMode().translateY(event.getY()); final HitInfo hitInfo = graph.getGraph().getHitInfo(x, y); if (hitInfo.hasHitNodes()) { final Node n = hitInfo.getHitNode(); if (SwingUtilities.isLeftMouseButton(event) && !event.isAltDown()) { if (n == m_node) { if (!m_isDragging) { // Change caret CEditNodeHelper.setCaretEnd(graph, n, event); } else { m_isDragging = false; } return new CStateChange(this, false); } else { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createNodePressedLeftState(n, event), true); } } else if (SwingUtilities.isRightMouseButton(event)) { if (n == m_node) { // Show context menu // NH 10.08.2010 // m_factory.editNodeRightClicked(m_node, event, x, y); return new CStateChange(this, false); } else { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createNodePressedRightState(n, event), true); } } else if (SwingUtilities.isMiddleMouseButton(event) || (event.isAltDown() && SwingUtilities.isLeftMouseButton(event))) { if (n == m_node) { // m_factory.createNodeEditExitState(m_node, event); if (!m_isDragging) { // Change caret CEditNodeHelper.setCaretEnd(graph, n, event); } else { m_isDragging = false; } return new CStateChange(this, false); } else { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createNodePressedMiddleState(n, event), true); } } else { // A button was pressed that does not have any special functionality. return new CStateChange(this, false); } } else if (hitInfo.hasHitNodeLabels()) { throw new IllegalStateException(); } else if (hitInfo.hasHitEdges()) { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdge(), event), true); } else if (hitInfo.hasHitEdgeLabels()) { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdgeLabel() .getEdge(), event), true); } else if (hitInfo.hasHitBends()) { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createBendPressedLeftState(hitInfo.getHitBend(), event), true); } else if (hitInfo.hasHitPorts()) { m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createDefaultState(), true); } else { // User left-pressed the background. m_factory.createNodeEditExitState(m_node, event); return new CStateChange(m_factory.createBackgroundPressedLeftState(event), true); } }
Example 18
Source File: UIMouse.java From open-ig with GNU Lesser General Public License v3.0 | 4 votes |
/** * Create an UIMouse from a Mouse Event. * @param e the mouse event * @return the UI mouse */ public static UIMouse from(MouseEvent e) { UIMouse m = new UIMouse(); m.x = e.getX(); m.y = e.getY(); if (SwingUtilities.isLeftMouseButton(e)) { m.buttons.add(Button.LEFT); } if (SwingUtilities.isMiddleMouseButton(e)) { m.buttons.add(Button.MIDDLE); } if (SwingUtilities.isRightMouseButton(e)) { m.buttons.add(Button.RIGHT); } if (e.isShiftDown()) { m.modifiers.add(Modifier.SHIFT); } if (e.isControlDown()) { m.modifiers.add(Modifier.CTRL); } if (e.isAltDown()) { m.modifiers.add(Modifier.ALT); } switch (e.getID()) { case MouseEvent.MOUSE_CLICKED: m.type = e.getClickCount() == 1 ? Type.CLICK : Type.DOUBLE_CLICK; m.z = e.getClickCount(); break; case MouseEvent.MOUSE_PRESSED: m.type = Type.DOWN; break; case MouseEvent.MOUSE_RELEASED: m.type = Type.UP; break; case MouseEvent.MOUSE_MOVED: m.type = Type.MOVE; break; case MouseEvent.MOUSE_DRAGGED: m.type = Type.DRAG; break; case MouseEvent.MOUSE_ENTERED: m.type = Type.ENTER; break; case MouseEvent.MOUSE_EXITED: m.type = Type.LEAVE; break; case MouseEvent.MOUSE_WHEEL: m.type = Type.WHEEL; m.z = ((MouseWheelEvent)e).getUnitsToScroll(); break; default: } return m; }
Example 19
Source File: JavaWindowsView.java From visualvm with GNU General Public License v2.0 | 4 votes |
public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) handleClick(e); if (SwingUtilities.isMiddleMouseButton(e)) handleMiddleClick(e); }