java.awt.event.MouseEvent#BUTTON1()源码实例Demo

下面列出了java.awt.event.MouseEvent#BUTTON1() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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 ) );
    }
  }
}
 
源代码2 项目: TencentKona-8   文件: XMBeanAttributes.java
@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);
        }
    }
}
 
源代码3 项目: Course_Generator   文件: CGMapController.java
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;
	}
}
 
源代码4 项目: Creatures   文件: WorldInputListener.java
@Override
public void mouseReleased(MouseEvent e) {
	if (e.getButton() == MouseEvent.BUTTON1) {
		leftButtonPressed = false;
	}
	else if (e.getButton() == MouseEvent.BUTTON3) {
		rightButtonPressed = false;
	}
}
 
源代码5 项目: jdk8u_jdk   文件: bug6690791.java
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);
}
 
源代码6 项目: drmips   文件: DlgAbout.java
@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);
	}
}
  }
 
源代码7 项目: binnavi   文件: CResultsTable.java
@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());
  }
}
 
源代码8 项目: algs4   文件: Draw.java
/**
 * 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()));
    }
}
 
源代码9 项目: openjdk-jdk8u   文件: XMBeanAttributes.java
@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);
        }
    }
}
 
源代码10 项目: stendhal   文件: InternalManagedWindow.java
@Override
public void mouseClicked(final MouseEvent ev) {
	if (ev.getButton() == MouseEvent.BUTTON1) {
		/*
		 * Raise the window if possible.
		 */
		raise();
	}
}
 
源代码11 项目: Course_Generator   文件: FrmMiniroadbook.java
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;
}
 
源代码12 项目: jdk8u-dev-jdk   文件: XToolkit.java
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;
}
 
源代码13 项目: mzmine2   文件: ChartGesture.java
/**
 * 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;
}
 
源代码14 项目: TencentKona-8   文件: ExtendedPanAction.java
@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;
}
 
源代码15 项目: Spade   文件: Picker.java
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);
	}
}
 
源代码16 项目: ghidra   文件: VersionHistoryPanel.java
private void handleMouseClick(MouseEvent e) {
	if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
		int row = table.rowAtPoint(e.getPoint());
		if (row < 0) {
			return;
		}
		open();
	}
}
 
源代码17 项目: sldeditor   文件: CharMap4Grid.java
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
}
 
源代码18 项目: pentaho-reporting   文件: FilesTree.java
public void mouseClicked( final MouseEvent e ) {
  if ( e.getClickCount() >= 2 && e.getButton() == MouseEvent.BUTTON1 ) {
    performDefaultAction();
  }
}
 
源代码19 项目: netbeans   文件: GlassPane.java
@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();
        }
 
源代码20 项目: pentaho-reporting   文件: TypedHeaderCellEditor.java
/**
 * 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;
}