Java Code Examples for javax.swing.SwingUtilities#isRightMouseButton()
The following examples show how to use
javax.swing.SwingUtilities#isRightMouseButton() .
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: NavigableImagePanel.java From Ngram-Graphs with Apache License 2.0 | 6 votes |
public void mouseClicked(MouseEvent e) { Point p = e.getPoint(); if (SwingUtilities.isRightMouseButton(e)) { if (isInNavigationImage(p)) { navZoomFactor = 1.0 - zoomIncrement; zoomNavigationImage(); } else if (isInImage(p)) { zoomFactor = 1.0 - zoomIncrement; zoomImage(); } } else { if (isInNavigationImage(p)) { navZoomFactor = 1.0 + zoomIncrement; zoomNavigationImage(); } else if (isInImage(p)) { zoomFactor = 1.0 + zoomIncrement; zoomImage(); } } }
Example 2
Source File: EditVertexTool.java From jts with GNU Lesser General Public License v2.1 | 6 votes |
public void mousePressed(MouseEvent e) { currentVertexLoc = null; if (SwingUtilities.isRightMouseButton(e)) return; // initiate moving a vertex Coordinate mousePtModel = toModelCoordinate(e.getPoint()); double tolModel = getModelSnapTolerance(); selectedVertexLocation = geomModel().locateVertexPt(mousePtModel, tolModel); if (selectedVertexLocation != null) { adjVertices = geomModel().findAdjacentVertices(selectedVertexLocation); currentVertexLoc = selectedVertexLocation; redrawIndicator(); } }
Example 3
Source File: CourseTabFactory.java From tmc-intellij with MIT License | 6 votes |
private void addRightMouseButtonFunctionality(MouseEvent mouseEvent, final JBList list, JBScrollPane panel) { logger.info("Adding functionality for right mouse button. @CourseTabFactory"); if (!SwingUtilities.isRightMouseButton(mouseEvent)) { return; } int index = list.locationToIndex(mouseEvent.getPoint()); list.setSelectedIndex(index); PopUpMenu menu = new PopUpMenu(); JBMenuItem openInExplorer = new JBMenuItem("Open path"); final Object selectedItem = list.getSelectedValue(); JBMenuItem deleteFolder = new JBMenuItem("Delete folder"); openInExplorer.addActionListener(createOpenInExploreListener(list, selectedItem)); deleteFolder.addActionListener(createDeleteButtonActionListener(list, selectedItem)); menu.add(openInExplorer); menu.add(deleteFolder); menu.show(panel, mouseEvent.getX(), mouseEvent.getY()); menu.setLocation(mouseEvent.getXOnScreen(), mouseEvent.getYOnScreen()); }
Example 4
Source File: ResultsTableWindow.java From thunderstorm with GNU General Public License v3.0 | 6 votes |
@Override protected void tableMouseClicked(MouseEvent e) { if(SwingUtilities.isLeftMouseButton(e)) { if(e.getClickCount() == 2) { IJResultsTable rt = IJResultsTable.getResultsTable(); int row = table.getSelectedRow(); int rowIndex = rt.convertViewRowIndexToModel(row); Molecule mol = rt.getRow(rowIndex); if(mol.hasParam(LABEL_DETECTIONS)) { if(mol.getParam(LABEL_DETECTIONS) > 1) { List<Molecule> detections = mol.getDetections(); Collections.sort(detections); new MergedMoleculesPopUp(table, row, 0, detections); } } } } else if(SwingUtilities.isRightMouseButton(e)) { if(table.getSelectedRowCount() > 0) { new TableRowsPopUpMenu(e, this); } } }
Example 5
Source File: CardsLegalityPanel.java From magarena with GNU General Public License v3.0 | 6 votes |
private MouseAdapter getTableMouseAdapter() { return new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (!isAdjusting) { int mouseRow = table.rowAtPoint(e.getPoint()); MagicCardDefinition card = tableModel.getCardDef(mouseRow); card = card == null ? MagicCardDefinition.UNKNOWN : card; if (SwingUtilities.isLeftMouseButton(e)) { notifyOnLeftClick(card); } else if (SwingUtilities.isRightMouseButton(e)) { notifyOnRightClick(card); } } } }; }
Example 6
Source File: RubberBand.java From tn5250j with GNU General Public License v2.0 | 6 votes |
@Override public void mouseDragged(MouseEvent e) { if(!SwingUtilities.isRightMouseButton(e) && getCanvas().canDrawRubberBand(RubberBand.this)) { erase(); if (!isDragging) { reset(); start(canvas.translateStart(e.getPoint())); } isDragging = true; stop(canvas.translateEnd(e.getPoint())); notifyRubberBandCanvas(); draw(); notifyRubberBandCanvas(); } }
Example 7
Source File: CardTablePanelA.java From magarena with GNU General Public License v3.0 | 6 votes |
private MouseAdapter getTableMouseAdapter() { return new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (!isAdjusting) { if (SwingUtilities.isLeftMouseButton(e)) { if (hasDoubleClickListeners() && e.getClickCount() == 2) { firePropertyChange(CP_CARD_DCLICKED, false, true); } else { firePropertyChange(CP_CARD_LCLICKED, false, true); } } else if (SwingUtilities.isRightMouseButton(e)) { final Point p = e.getPoint(); final int rowNumber = table.rowAtPoint(p); final boolean isRowSelected = table.isRowSelected(rowNumber); if (!isRowSelected) { table.getSelectionModel().setSelectionInterval(rowNumber, rowNumber); } else { firePropertyChange(CP_CARD_RCLICKED, false, true); } } } } }; }
Example 8
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 9
Source File: JMarkerEdit.java From nordpos with GNU General Public License v3.0 | 5 votes |
private void JMapViewerMouseClicked(java.awt.event.MouseEvent evt) { ICoordinate icoord = map().getPosition(evt.getPoint()); if (SwingUtilities.isRightMouseButton(evt) && evt.getClickCount() == 1) { map().removeMapMarker(mapMarker); mapMarker.setLat(icoord.getLat()); mapMarker.setLon(icoord.getLon()); map().addMapMarker(mapMarker); } }
Example 10
Source File: DeckTablePanel.java From magarena with GNU General Public License v3.0 | 5 votes |
private void doMousePressedAction(MouseEvent e) { if (isMouseRowSelected(e)) { if (SwingUtilities.isLeftMouseButton(e)) { doLeftClickAction(); } else if (SwingUtilities.isRightMouseButton(e)) { doRightClickAction(); } } }
Example 11
Source File: QueryRangeSelectionAdapter.java From bboxdb with Apache License 2.0 | 5 votes |
@Override public void mousePressed(final MouseEvent e) { if (!SwingUtilities.isRightMouseButton(e)) { return; } startPos.setLocation(e.getX(), e.getY()); dragging = true; }
Example 12
Source File: PalettePanel.java From netbeans with Apache License 2.0 | 5 votes |
private MouseListener mouseListener() { if( null == mouseListener ) { mouseListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { if( SwingUtilities.isRightMouseButton( event ) && null != model ) { JPopupMenu popup = Utilities.actionsToPopup( model.getActions(), PalettePanel.this ); Utils.addCustomizationMenuItems( popup, getController(), getSettings() ); popup.show( (Component)event.getSource(), event.getX(), event.getY() ); } } }; } return mouseListener; }
Example 13
Source File: RubberBand.java From tn5250j with GNU General Public License v2.0 | 5 votes |
@Override public void mousePressed(MouseEvent e) { if (!SwingUtilities.isRightMouseButton(e)) { if (!isSomethingBounded) start(canvas.translateStart(e.getPoint())); else { // if (isSomethingBounded) { // erase(); // notifyRubberBandCanvas(); // reset(); // start(canvas.translateStart(e.getPoint())); // } } } }
Example 14
Source File: MTabbedPane.java From javamelody with Apache License 2.0 | 5 votes |
void mouseClicked(MouseEvent event) { // we only look at the right button if (SwingUtilities.isRightMouseButton(event)) { final JPopupMenu menu = createPopupMenu(); menu.show(this, event.getX(), event.getY()); } }
Example 15
Source File: UIPredicates.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
/** * Predicate to check if a context selection is wanted. * Default is the typical pressing with Right button only. * * @param e the mouse context * @return the predicate result */ public static boolean isContextWanted (MouseEvent e) { if (WellKnowns.MAC_OS_X) { return e.isPopupTrigger(); } else { return SwingUtilities.isRightMouseButton(e) && !SwingUtilities.isLeftMouseButton(e); } }
Example 16
Source File: TimerFrame.java From training with MIT License | 5 votes |
public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e) ) { //right click return; } else if (e.getClickCount() == 1) { oneClick(); } else if (e.getClickCount() == 2) { doubleClick(); } }
Example 17
Source File: MainFrame.java From android-screen-monitor with Apache License 2.0 | 4 votes |
public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { mPopupMenu.show(e.getComponent(), e.getX(), e.getY()); } }
Example 18
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 19
Source File: AnnotationEventHook.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
@Override public void processMouseEvent(final ExecutionUnit process, final MouseEventType type, final MouseEvent e) { if (!visualizer.isActive()) { return; } Point point = rendererModel.getMousePositionRelativeToProcess(); if (point == null) { point = e.getPoint(); } switch (type) { case MOUSE_CLICKED: if (!SwingUtilities.isLeftMouseButton(e)) { break; } if (process != null && e.getClickCount() >= 2) { if (!AnnotationDrawer.isProcessInteractionHappening(rendererModel)) { double x = Math.max(WorkflowAnnotation.MIN_X, point.getX()); double y = Math.max(WorkflowAnnotation.MIN_Y, point.getY()); ProcessAnnotation anno = new ProcessAnnotation( I18N.getGUILabel("workflow.annotation.default_text.label"), new AnnotationStyle(), process, false, false, new Rectangle2D.Double(x, y, ProcessAnnotation.DEFAULT_WIDTH, ProcessAnnotation.DEFAULT_HEIGHT)); model.addProcessAnnotation(anno); decorator.editSelected(); e.consume(); } } break; case MOUSE_ENTERED: case MOUSE_MOVED: if (process != null) { WorkflowAnnotations annotations = rendererModel.getProcessAnnotations(process); if (updateHoveredStatus(point, process, annotations)) { updateHyperlinkHoverStatus(point); e.consume(); } else { model.setHovered(null, null); } } break; case MOUSE_EXITED: if (!SwingTools.isMouseEventExitedToChildComponents(view, e)) { model.setHovered(null, null); } break; case MOUSE_DRAGGED: model.setHovered(null, null); break; case MOUSE_PRESSED: if ((SwingTools.isControlOrMetaDown(e) || e.isShiftDown()) && e.getButton() == 1) { return; } if (SwingUtilities.isLeftMouseButton(e) || SwingUtilities.isRightMouseButton(e)) { handleMousePressedForUnselectedAnnotations(e, point); } break; case MOUSE_RELEASED: default: break; } }
Example 20
Source File: OverlayRenderer.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Override public MouseEvent mousePressed(MouseEvent mouseEvent) { if (!inOverlayManagingMode) { return mouseEvent; } final Point mousePoint = mouseEvent.getPoint(); mousePosition.setLocation(mousePoint); if (currentManagedOverlay == null) { return mouseEvent; } if (SwingUtilities.isRightMouseButton(mouseEvent)) { if (currentManagedOverlay.isResettable()) { overlayManager.resetOverlay(currentManagedOverlay); } } else if (SwingUtilities.isLeftMouseButton(mouseEvent)) { final Point offset = new Point(mousePoint.x, mousePoint.y); offset.translate(-currentManagedOverlay.getBounds().x, -currentManagedOverlay.getBounds().y); overlayOffset.setLocation(offset); inOverlayResizingMode = currentManagedOverlay != null && currentManagedOverlay.isResizable() && clientUI.getCurrentCursor() != clientUI.getDefaultCursor(); inOverlayDraggingMode = !inOverlayResizingMode; startedMovingOverlay = true; currentManagedBounds = new Rectangle(currentManagedOverlay.getBounds()); } else { return mouseEvent; } mouseEvent.consume(); return mouseEvent; }