Java Code Examples for java.awt.event.MouseEvent#BUTTON1
The following examples show how to use
java.awt.event.MouseEvent#BUTTON1 .
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: Draw.java From algs4 with GNU General Public License v3.0 | 5 votes |
/** * This method cannot be called directly. */ @Override public void mouseReleased(MouseEvent e) { synchronized (mouseLock) { isMousePressed = false; } if (e.getButton() == MouseEvent.BUTTON1) { for (DrawListener listener : listeners) listener.mouseReleased(userX(e.getX()), userY(e.getY())); } }
Example 2
Source File: VersionHistoryPanel.java From ghidra with Apache License 2.0 | 5 votes |
private void handleMouseClick(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { int row = table.rowAtPoint(e.getPoint()); if (row < 0) { return; } open(); } }
Example 3
Source File: Picker.java From Spade with GNU General Public License v3.0 | 5 votes |
public void whilePressed(Layer layer, short x, short y, int button) { if(x < 0 || y < 0 || x >= layer.getWidth() || y >= layer.getHeight()) return; if(button == MouseEvent.BUTTON1) { Spade.main.setLeftColour(layer.getImage().getPixel(x, y), false); } else if(button == MouseEvent.BUTTON3) { Spade.main.setRightColour(layer.getImage().getPixel(x, y), false); } }
Example 4
Source File: ExtendedPanAction.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public State mousePressed(Widget widget, WidgetMouseEvent event) { if (event.getButton() == MouseEvent.BUTTON2 || event.getButton() == MouseEvent.BUTTON1 && ((event.getModifiers() & MouseEvent.CTRL_MASK) != 0)) { scene = widget.getScene(); scrollPane = findScrollPane(scene.getView()); if (scrollPane != null) { lastLocation = scene.convertSceneToView(widget.convertLocalToScene(event.getPoint())); SwingUtilities.convertPointToScreen(lastLocation, scrollPane.getViewport().getView()); return State.createLocked(widget, this); } } return State.REJECTED; }
Example 5
Source File: ChartGesture.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * returns the BUTTON for a MouseEvent.BUTTON * * @param mouseeventbutton * @return */ public static Button getButton(int mouseeventbutton) { switch (mouseeventbutton) { case MouseEvent.BUTTON1: return BUTTON1; case MouseEvent.BUTTON2: return BUTTON2; case MouseEvent.BUTTON3: return BUTTON3; } return null; }
Example 6
Source File: XToolkit.java From jdk8u-dev-jdk with 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 7
Source File: FrmMiniroadbook.java From Course_Generator with 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 8
Source File: InternalManagedWindow.java From stendhal with GNU General Public License v2.0 | 5 votes |
@Override public void mouseClicked(final MouseEvent ev) { if (ev.getButton() == MouseEvent.BUTTON1) { /* * Raise the window if possible. */ raise(); } }
Example 9
Source File: XMBeanAttributes.java From openjdk-jdk8u with 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 10
Source File: VerticalLinealComponent.java From pentaho-reporting with 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 11
Source File: CResultsTable.java From binnavi with Apache License 2.0 | 5 votes |
@Override public void mouseClicked(final MouseEvent event) { if ((event.getButton() == MouseEvent.BUTTON1) && (event.getClickCount() == 2)) { final int sortedRow = rowAtPoint(event.getPoint()); if (sortedRow == -1) { return; } final int row = convertRowIndexToModel(sortedRow); ZyZoomHelpers.zoomToInstruction(m_graph, m_model.getInstruction(row).getInstruction()); } }
Example 12
Source File: DlgAbout.java From drmips with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("UseSpecificCatch") private void lblHomepageMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblHomepageMouseClicked if(evt.getButton() == MouseEvent.BUTTON1) { try { Desktop.getDesktop().browse(new URI(AppInfo.HOMEPAGE)); } catch(Exception ex) { LOG.log(Level.WARNING, "error opening web browser", ex); JOptionPane.showMessageDialog(this, Lang.t("failed_to_open_web_browser"), AppInfo.NAME, JOptionPane.ERROR_MESSAGE); } } }
Example 13
Source File: bug6690791.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED, System.currentTimeMillis(), MouseEvent.ALT_MASK, 10, 10, 100, 100, 1, false, MouseEvent.BUTTON1); me.setSource(new Object()); MenuSelectionManager.defaultManager().processMouseEvent(me); }
Example 14
Source File: WorldInputListener.java From Creatures with GNU General Public License v2.0 | 5 votes |
@Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { leftButtonPressed = false; } else if (e.getButton() == MouseEvent.BUTTON3) { rightButtonPressed = false; } }
Example 15
Source File: CGMapController.java From Course_Generator with GNU General Public License v3.0 | 5 votes |
public void mouseReleased(MouseEvent e) { debugMouseEvent("DefaultMapController.mouseReleased", e); if (e.getButton() == movementMouseButton || isPlatformOsx() && e.getButton() == MouseEvent.BUTTON1) { if (JMapViewer.debug) { System.err.println("(#9897) move stop"); } lastDragPoint = null; isMoving = false; } }
Example 16
Source File: XMBeanAttributes.java From TencentKona-8 with 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 17
Source File: FilesTree.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void mouseClicked( final MouseEvent e ) { if ( e.getClickCount() >= 2 && e.getButton() == MouseEvent.BUTTON1 ) { performDefaultAction(); } }
Example 18
Source File: CharMap4Grid.java From sldeditor with GNU General Public License v3.0 | 4 votes |
public void mouseReleased(MouseEvent event) { // Called after a mouse button is released, and before mouseClicked(). If // the mouse moves too much, then Java doesn't call mouseClicked(), so we use // this method to implement our own rules for how much a mouse can move while // being clicked. int index; // cell index for character or glyph boolean repaint; // true if we should repaint our display index = convertMouse(event); // convert pixel coordinates to index value repaint = false; // assume that we won't need to repaint if ((index >= 0) // only if mouse is over defined character && (clickIndex == index) // and it's the same as when mouse pressed && (Math.abs(clickStartX - event.getX()) <= MOUSE_DRIFT) && (Math.abs(clickStartY - event.getY()) <= MOUSE_DRIFT)) { /* Mouse is over a defined character or glyph. */ if ((event.getButton() != MouseEvent.BUTTON1) // right means not primary || event.isAltDown() || event.isControlDown() || event.isShiftDown()) { // TODO // CharMap4.rightSaveCaption = CharMap4.statusDialog.getText(); // caption // CharMap4.rightSaveChar = cellChar[index]; // save character number // CharMap4.rightSaveGlyph = cellGlyph[index]; // save glyph number // // CharMap4.rightCopyCaption.setEnabled((CharMap4.rightSaveCaption != null) // && (CharMap4.rightSaveCaption.length() > 0)); // CharMap4.rightCopyGlyph.setEnabled(CharMap4.rightSaveGlyph >= 0); // CharMap4.rightCopyNotation.setEnabled(CharMap4.rightSaveChar >= 0); // CharMap4.rightCopyNumber.setEnabled(CharMap4.rightSaveChar >= 0); // CharMap4.rightCopyText.setEnabled(CharMap4.rightSaveChar >= 0); } else { // A left click or primary button click copies the character as text, // if there is a unique character number. if (cellChar[index] >= 0) { mouseReplaceText(CharMap4.unicodeNotation(cellChar[index]), index); } } } // Avoid redrawing the screen unless the mouse has changed cells. if (clickIndex >= 0) // mouse release always ends click highlight { clickIndex = NO_MOUSE; // this character is no longer highlighted repaint = true; // mark ourselves as needing to be repainted } clickStartX = clickStartY = NO_MOUSE; // no starting coordinates for click if (hoverIndex != index) // has there been a change in position? { hoverIndex = index; // turn on highlighting for this character repaint = true; // mark ourselves as needing to be repainted } if (repaint) this.repaint(); // repaint our display if something changed }
Example 19
Source File: GlassPane.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void mousePressed(MouseEvent e) { Point point = e.getPoint(); draggingStart = point; boolean leftMousePressed = (e.getButton() == MouseEvent.BUTTON1); boolean rightMousePressed = (e.getButton() == MouseEvent.BUTTON3); if (leftMousePressed) { if (resizingMode == 0) { focusedComponent = findComponent(point); if (e.isPopupTrigger()) { // Mac if (!selection.contains(focusedComponent)) { setSelection(focusedComponent); } showPopupMenu(point); } else if (!e.isShiftDown()) { // shift adding to selection on mouse release if (focusedComponent != null && ctrlOrCmdModifier(e)) { Set<Component> newSelection = new HashSet<Component>(); newSelection.addAll(selection); if (selection.contains(focusedComponent)) { newSelection.remove(focusedComponent); } else { newSelection.add(focusedComponent); } setSelection(newSelection); } else if (!selection.contains(focusedComponent)) { setSelection(focusedComponent); } } // // Column selection // int column = findColumnHeader(point); // if (column != -1) { //// selectedColumns.flip(column); // } // // Row selection // int row = findRowHeader(point); // if (row != -1) { //// selectedRows.flip(row); // } } else { // Resizing (start) resizing = true; requestFocusInWindow(); draggingRect = fromComponentPane(selectionResizingBounds(focusedComponent)); newGridX = gridInfo.getGridX(focusedComponent); newGridY = gridInfo.getGridY(focusedComponent); newGridHeight = gridInfo.getGridHeight(focusedComponent); newGridWidth = gridInfo.getGridWidth(focusedComponent); initSelFields(); } } else if (rightMousePressed) { if (moving || resizing) { moving = false; resizing = false; draggingStart = null; } else { focusedComponent = findComponent(point); if (!selection.contains(focusedComponent)) { setSelection(focusedComponent); } if (e.isPopupTrigger()) { // Linux showPopupMenu(point); } } } repaint(); }
Example 20
Source File: TypedHeaderCellEditor.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 3 votes |
/** * Asks the editor if it can start editing using <code>anEvent</code>. <code>anEvent</code> is in the invoking * component coordinate system. The editor can not assume the Component returned by * <code>getCellEditorComponent</code> is installed. This method is intended for the use of client to avoid the cost * of setting up and installing the editor component if editing is not possible. If editing can be started this method * returns true. * * @param anEvent the event the editor should use to consider whether to begin editing or not * @return true if editing can be started * @see #shouldSelectCell */ public boolean isCellEditable( final EventObject anEvent ) { if ( anEvent instanceof MouseEvent ) { final MouseEvent mouseEvent = (MouseEvent) anEvent; return mouseEvent.getClickCount() >= 2 && mouseEvent.getButton() == MouseEvent.BUTTON1; } return true; }