Java Code Examples for java.awt.event.MouseEvent#getButton()
The following examples show how to use
java.awt.event.MouseEvent#getButton() .
These examples are extracted from open source projects.
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 Project: rtg-tools File: RocLinesPanel.java License: BSD 2-Clause "Simplified" License | 6 votes |
@Override public void mouseReleased(MouseEvent e) { if (mIsDragging && e.getButton() == MouseEvent.BUTTON1) { final int deltaY = e.getYOnScreen() - mOriginalScreenY; final int newY = mOriginalY + deltaY; final Component[] components = getComponents(); // Find new position for mPanel (it is currently at position 0 due to Z order) int i; for (i = 1; i < components.length; ++i) { if (components[i].getY() >= newY) { break; } } mPanel.setBorder(mBorder); remove(mPanel); add(mPanel, i - 1); updateCurves(); mIsDragging = false; } }
Example 2
Source Project: runelite File: GrandExchangeInputListener.java License: BSD 2-Clause "Simplified" License | 6 votes |
@Override public MouseEvent mouseClicked(MouseEvent e) { // Check if left click + alt if (e.getButton() == MouseEvent.BUTTON1 && e.isAltDown()) { final MenuEntry[] menuEntries = client.getMenuEntries(); for (final MenuEntry menuEntry : menuEntries) { if (menuEntry.getOption().equals(SEARCH_GRAND_EXCHANGE)) { search(Text.removeTags(menuEntry.getTarget())); e.consume(); break; } } } return super.mouseClicked(e); }
Example 3
Source Project: javamoney-examples File: SearchWidget.java License: Apache License 2.0 | 6 votes |
@Override public void mousePressed(MouseEvent event) { if(event.getSource() == getLabels()[RIGHT_LABEL] && event.getButton() == BUTTON1) { // Icons are only displayed on the right when the text field has focus. if(getField().hasFocus() == true) { if(getLabels()[RIGHT_LABEL].getIcon() == SEARCH_CLEAR.getIcon()) { getLabels()[RIGHT_LABEL].setIcon(SEARCH_CLEAR_PRESSED.getIcon()); } } } }
Example 4
Source Project: openAGV File: ViewDragScrollListener.java License: Apache License 2.0 | 6 votes |
@Override public void mouseReleased(MouseEvent evt) { if (dragIsSelected()) { return; } final OpenTCSDrawingView drawingView = scrollPane.getDrawingView(); Figure fig = drawingView.findFigure(evt.getPoint()); if (fig instanceof LabeledPointFigure) { createPossibleTransportOrder((LabeledPointFigure) fig, drawingView.getSelectedFigures()); } pressedFigure = null; fMouseEndPoint.setLocation(drawingView.viewToDrawing(evt.getPoint())); if (evt.getButton() != 2) { showPositionStatus(true); } else { showPositionStatus(false); } }
Example 5
Source Project: consulo File: ContentTabLabel.java License: Apache License 2.0 | 6 votes |
@Override protected void execute(final MouseEvent e) { Optional<Runnable> first = myAdditionalIcons.stream().filter(icon -> mouseOverIcon(icon)).map(icon -> icon.getAction()).findFirst(); if (first.isPresent()) { first.get().run(); return; } selectContent(); if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !myLayout.myDoubleClickActions.isEmpty()) { DataContext dataContext = DataManager.getInstance().getDataContext(ContentTabLabel.this); for (AnAction action : myLayout.myDoubleClickActions) { AnActionEvent event = AnActionEvent.createFromInputEvent(e, ActionPlaces.UNKNOWN, null, dataContext); if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) { ActionManagerEx.getInstanceEx().fireBeforeActionPerformed(action, dataContext, event); ActionUtil.performActionDumbAware(action, event); } } } }
Example 6
Source Project: TencentKona-8 File: Ruler.java License: GNU General Public License v2.0 | 5 votes |
@Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { x = e.getX(); y = e.getY(); } }
Example 7
Source Project: runelite File: MouseManager.java License: BSD 2-Clause "Simplified" License | 5 votes |
private void checkExtraMouseButtons(MouseEvent mouseEvent) { // Prevent extra mouse buttons from being passed into the client, // as it treats them all as left click int button = mouseEvent.getButton(); if (button >= MOUSE_BUTTON_4 && runeLiteConfig.blockExtraMouseButtons()) { mouseEvent.consume(); } }
Example 8
Source Project: Course_Generator File: FrmMiniroadbook.java License: GNU General Public License v3.0 | 5 votes |
protected String ManageMemories(MouseEvent e, String memo) { if (datalist.data.isEmpty()) return memo; int row = TableData.getSelectedRow(); if (row < 0) return memo; // -- Left click if (e.getButton() == MouseEvent.BUTTON1) { int line = (int) datalist.data.get(row).getNum() - 1; if (line > track.data.size()) return memo; String txt = memo; tfFormat.setText(txt); track.data.get(line).FmtLbMiniRoadbook = txt; datalist.data.get(row).FmtLbMiniRoadbook = txt; track.isModified = true; RefreshTableData(); pnlProfil.Refresh(); } // -- Right click else if (e.getButton() == MouseEvent.BUTTON3) { memo = tfFormat.getText(); track.isModified = true; // RefreshTooltips(); } return memo; }
Example 9
Source Project: pentaho-reporting File: VerticalLinealComponent.java License: GNU Lesser General Public License v2.1 | 5 votes |
public void mousePressed( final MouseEvent e ) { final int padding = (int) getPadding(); if ( e.getX() < padding ) { return; } if ( e.getButton() == MouseEvent.BUTTON1 ) { guideLineIndex = getActiveGuideIndex( e ); if ( guideLineIndex != -1 ) { setDraggedGuideLine( getLinealModel().getGuideLine( guideLineIndex ) ); } } }
Example 10
Source Project: jdk8u-dev-jdk File: XMBeanAttributes.java License: GNU General Public License v2.0 | 5 votes |
@Override public void mousePressed(MouseEvent e) { if(e.getButton() == MouseEvent.BUTTON1) { if(e.getClickCount() >= 2) { int row = XMBeanAttributes.this.getSelectedRow(); int col = XMBeanAttributes.this.getSelectedColumn(); if(col != VALUE_COLUMN) return; if(col == -1 || row == -1) return; XMBeanAttributes.this.updateZoomedCell(row, col); } } }
Example 11
Source Project: javamoney-examples File: DataElementPanel.java License: Apache License 2.0 | 5 votes |
@Override public void mouseClicked(MouseEvent event) { if(event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2) { // Make sure the user double-clicked on an element. if(getChooser().getRowForLocation(event.getX(), event.getY()) != -1) { edit(); } } }
Example 12
Source Project: openjdk-jdk8u-backup File: XMBeanAttributes.java License: GNU General Public License v2.0 | 5 votes |
@Override public void mousePressed(MouseEvent e) { if(e.getButton() == MouseEvent.BUTTON1) { if(e.getClickCount() >= 2) { int row = XMBeanAttributes.this.getSelectedRow(); int col = XMBeanAttributes.this.getSelectedColumn(); if(col != VALUE_COLUMN) return; if(col == -1 || row == -1) return; XMBeanAttributes.this.updateZoomedCell(row, col); } } }
Example 13
Source Project: radiance File: RolloverButtonListener.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void mouseEntered(MouseEvent e) { this.stateTransitionTracker.turnOffModelChangeTracking(); try { super.mouseEntered(e); this.isMouseInside = true; boolean isMouseDrag = (e.getButton() == MouseEvent.BUTTON1); if (!isMouseDrag) { this.button.getModel().setRollover(true); } } finally { this.stateTransitionTracker.onModelStateChanged(); } }
Example 14
Source Project: algs4 File: Draw.java License: GNU General Public License v3.0 | 5 votes |
/** * This method cannot be called directly. */ @Override public void mousePressed(MouseEvent e) { synchronized (mouseLock) { mouseX = userX(e.getX()); mouseY = userY(e.getY()); isMousePressed = true; } if (e.getButton() == MouseEvent.BUTTON1) { for (DrawListener listener : listeners) listener.mousePressed(userX(e.getX()), userY(e.getY())); } }
Example 15
Source Project: jdk8u60 File: XMBeanAttributes.java License: GNU General Public License v2.0 | 5 votes |
@Override public void mousePressed(MouseEvent e) { if(e.getButton() == MouseEvent.BUTTON1) { if(e.getClickCount() >= 2) { int row = XMBeanAttributes.this.getSelectedRow(); int col = XMBeanAttributes.this.getSelectedColumn(); if(col != VALUE_COLUMN) return; if(col == -1 || row == -1) return; XMBeanAttributes.this.updateZoomedCell(row, col); } } }
Example 16
Source Project: rcrs-server File: DeleteNodeTool.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { Point p = fixEventPoint(e.getPoint()); pressPoint = editor.getViewer().getCoordinatesAtPoint(p.x, p.y); overlay.setLeft(pressPoint.getX()); overlay.setBottom(pressPoint.getY()); editor.getViewer().addOverlay(overlay); editor.getViewer().repaint(); } }
Example 17
Source Project: hottub File: XToolkit.java License: GNU General Public License v2.0 | 5 votes |
static boolean isLeftMouseButton(MouseEvent me) { switch (me.getID()) { case MouseEvent.MOUSE_PRESSED: case MouseEvent.MOUSE_RELEASED: return (me.getButton() == MouseEvent.BUTTON1); case MouseEvent.MOUSE_ENTERED: case MouseEvent.MOUSE_EXITED: case MouseEvent.MOUSE_CLICKED: case MouseEvent.MOUSE_DRAGGED: return ((me.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0); } return false; }
Example 18
Source Project: WorldPainter File: BiomesViewerFrame.java License: GNU General Public License v3.0 | 5 votes |
@Override public void mousePressed(MouseEvent e) { if (e.getButton() != MouseEvent.BUTTON1) { return; } selecting = true; selectionCorner1 = getTileLocation(e.getX(), e.getY()); selectionCorner2 = null; imageViewer.setSelectedRectangleCorner1(null); imageViewer.setSelectedRectangleCorner2(null); }
Example 19
Source Project: settlers-remake File: GOSwingEventConverter.java License: MIT License | 5 votes |
@Override public void mouseReleased(MouseEvent e) { UIPoint local = convertToLocal(e); if (e.getButton() == MouseEvent.BUTTON1) { endDraw(local); } else if (panWithButton3 && e.getButton() == MouseEvent.BUTTON3) { endPan(local); } else if (!panWithButton3 && e.getButton() == MouseEvent.BUTTON2) { endPan(local); } }
Example 20
Source Project: pentaho-reporting File: QuerySelectorDialog.java License: GNU Lesser General Public License v2.1 | 4 votes |
public void mouseClicked( final MouseEvent e ) { if ( e.getClickCount() > 1 && e.getButton() == MouseEvent.BUTTON1 ) { setConfirmed( true ); QuerySelectorDialog.this.dispose(); } }