Java Code Examples for java.awt.event.MouseEvent#BUTTON1

The following examples show how to use java.awt.event.MouseEvent#BUTTON1 . 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
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 2
@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 3
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 4
@Override
public void mouseReleased(MouseEvent e) {
	if (e.getButton() == MouseEvent.BUTTON1) {
		leftButtonPressed = false;
	}
	else if (e.getButton() == MouseEvent.BUTTON3) {
		rightButtonPressed = false;
	}
}
 
Example 5
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 6
Source Project: drmips   File: DlgAbout.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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 7
Source Project: binnavi   File: CResultsTable.java    License: Apache License 2.0 5 votes vote down vote up
@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 8
Source Project: algs4   File: Draw.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 9
@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
@Override
public void mouseClicked(final MouseEvent ev) {
	if (ev.getButton() == MouseEvent.BUTTON1) {
		/*
		 * Raise the window if possible.
		 */
		raise();
	}
}
 
Example 11
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 12
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 13
/**
 * 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 14
@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 15
Source Project: Spade   File: Picker.java    License: GNU General Public License v3.0 5 votes vote down vote up
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 16
Source Project: ghidra   File: VersionHistoryPanel.java    License: Apache License 2.0 5 votes vote down vote up
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 17
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 18
public void mouseClicked( final MouseEvent e ) {
  if ( e.getClickCount() >= 2 && e.getButton() == MouseEvent.BUTTON1 ) {
    performDefaultAction();
  }
}
 
Example 19
Source Project: netbeans   File: GlassPane.java    License: Apache License 2.0 4 votes vote down vote up
@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
/**
 * 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;
}