Java 类java.awt.event.MouseEvent 实例源码

项目:Reinickendorf_SER316    文件:HTMLEditor.java   
private void maybeShowPopup(MouseEvent e) {
    if (e.isPopupTrigger()) {
        JPopupMenu popupMenu = new JPopupMenu();
        popupMenu.setFocusable(false);

        popupMenu.add(jMenuItemUndo);
        popupMenu.add(jMenuItemRedo);
        popupMenu.addSeparator();
        popupMenu.add(jMenuItemCut);
        popupMenu.add(jMenuItemCopy);
        popupMenu.add(jMenuItemPaste);
        popupMenu.addSeparator();
        if (jMenuItemInsCell.getAction().isEnabled()) {
            popupMenu.add(jMenuItemInsCell);
            jMenuItemInsCell.setEnabled(true);
            popupMenu.add(jMenuItemInsRow);
            jMenuItemInsRow.setEnabled(true);
            popupMenu.addSeparator();
        }
        popupMenu.add(jMenuItemProp);
        popupMenu.show(e.getComponent(), e.getX(), e.getY());

    }
}
项目:SpotSpotter    文件:CameraShot.java   
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 800, 450);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);

    final JButton btnNewButton = new JButton("\u62CD\u7167");
    btnNewButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent arg0) {
            flag = 1;// ��̬��������Ϊ1���Ӷ����°�ťʱ��ֹͣ����ͷ�ĵ���
        }
    });
    btnNewButton.setBounds(33, 13, 113, 27);
    frame.getContentPane().add(btnNewButton);

    label = new JLabel("");
    label.setBounds(0, 0, 800, 450);
    frame.getContentPane().add(label);
}
项目:Equella    文件:WorkflowTree.java   
@Override
public void mousePressed(final MouseEvent e)
{
    if( e.getButton() == MouseEvent.BUTTON3 )
    {
        setSelectionPath(getPathForLocation(e.getX(), e.getY()));
    }
    final WorkflowNode node = getSelectedNode();
    final boolean canedit = node != null && node.getParent() != model.getRoot();
    visible = (node == null && model.getRootNode() == null) || (node != null && node.canAddChildren());

    add.setVisible(visible);
    edit.setVisible(canedit);
    remove.setVisible(canedit);
    visible |= node != null;
}
项目:VASSAL-src    文件:Map.java   
/**
 * Mouse events are first translated into map coordinates.
 * Then the event is forwarded to the top MouseListener in the
 * stack, if any, otherwise forwarded to all LocalMouseListeners.
 *
 * @see #pushMouseListener
 * @see #popMouseListener
 * @see #addLocalMouseListener
 */
public void mouseReleased(MouseEvent e) {
  Point p = e.getPoint();
  p.translate(theMap.getX(), theMap.getY());
  if (theMap.getBounds().contains(p)) {
    if (!mouseListenerStack.isEmpty()) {
      p = mapCoordinates(e.getPoint());
      e.translatePoint(p.x - e.getX(), p.y - e.getY());
      mouseListenerStack.get(mouseListenerStack.size()-1).mouseReleased(e);
    }
    else if (multicaster != null) {
      p = mapCoordinates(e.getPoint());
      e.translatePoint(p.x - e.getX(), p.y - e.getY());
      multicaster.mouseReleased(e);
    }
    // Request Focus so that keyboard input will be recognized
    theMap.requestFocus();
  }
  // Clicking with mouse always repaints the map
  clearFirst = true;
  theMap.repaint();
  activeMap = this;
}
项目:cuttlefish    文件:PopupMousePlugin.java   
@SuppressWarnings("unchecked")
protected void handlePopup(MouseEvent e) {
       final VisualizationViewer<V,E> vv =
               (VisualizationViewer<V,E>)e.getSource();
       Point2D p = e.getPoint();

       GraphElementAccessor<V,E> pickSupport = vv.getPickSupport();
       if(pickSupport != null) {
           final V v = pickSupport.getVertex(vv.getGraphLayout(), p.getX(), p.getY());
           if(v != null) {
               updateVertexMenu(v, networkPanel, p);
               vertexPopup.show(vv, e.getX(), e.getY());
           } else {
               final E edge = pickSupport.getEdge(vv.getGraphLayout(), p.getX(), p.getY());
               if(edge != null) {
                   updateEdgeMenu(edge, networkPanel, p);
                   edgePopup.show(vv, e.getX(), e.getY());              
               }
           }
       }
   }
项目:A-Pathfinding-Visualization    文件:Frame.java   
@Override
// Track mouse on movement
public void mouseMoved(MouseEvent e) {
    int x = e.getX();
    int y = e.getY();
    int height = this.getHeight();

    // Detects if mouse is within button panel
    if(x >= 10 && x <= 332 && y >= (height-96) && y <= (height-6)) {
        btnHover = true;
    }
    else {
        btnHover = false;
    }
    repaint();
}
项目:DicomViewer    文件:PanelController.java   
@Override
public void mousePressed(MouseEvent e) {
    if (e.isShiftDown()) return;

    e.getComponent().requestFocus();
    if (e.getButton() == MouseEvent.BUTTON1) {
        dragAnim.stop();
        bDragging = true;
        dragMem = e.getPoint();
        dragWhen = e.getWhen();
    }
}
项目:The-Mysterious-Mind-Of-Jack    文件:Mouse.java   
public void mouseDragged(MouseEvent e) {
    mouseX = e.getX();
    mouseY = e.getY();
    if (SwingUtilities.isLeftMouseButton(e)) {
        mouseB = 1;
    }
    if (SwingUtilities.isRightMouseButton(e)) {
        mouseB = 3;
    }

    MouseDraggedEvent event = new MouseDraggedEvent(e.getX(), e.getY(), mouseB);
    try {
        eventListener.onEvent(event);
    } catch (Exception ex) {}
}
项目:JavaGraph    文件:RuleTree.java   
@Override
public void mousePressed(MouseEvent evt) {
    TreePath path = getPathForLocation(evt.getX(), evt.getY());
    if (path != null) {
        if (evt.getButton() == MouseEvent.BUTTON3 && !isRowSelected(getRowForPath(path))) {
            setSelectionPath(path);
        }
        DisplayKind toDisplay = null;
        Object lastComponent = path.getLastPathComponent();
        if (lastComponent instanceof RuleTreeNode) {
            toDisplay = DisplayKind.RULE;
        } else if (lastComponent instanceof RecipeTreeNode) {
            toDisplay = DisplayKind.CONTROL;
        } else if (lastComponent instanceof MatchTreeNode
            && getSimulatorModel().getDisplay() != DisplayKind.LTS) {
            toDisplay = DisplayKind.STATE;
        }
        if (evt.getClickCount() == 1 && toDisplay != null) {
            getSimulatorModel().setDisplay(toDisplay);
        } else if (evt.getClickCount() == 2 && toDisplay != null) {
            if (toDisplay.hasResource()) {
                getActions().getEditAction(toDisplay.getResource())
                    .execute();
            }
        }
    }
    maybeShowPopup(evt);
}
项目:candlelight    文件:Console.java   
protected void onContentMouseReleasedEvent(MouseEvent e)
{
    Point mousePoint = e.getPoint();
    mousePoint.x -= 0.5F;
    int index = this.textContent.viewToModel(mousePoint);

    if (index == -1) return;

    StyledDocument doc = this.getDocument();
    Element element = doc.getCharacterElement(index);

    LinkHandler handler = LinkHandler.getLinkHandler(element.getAttributes());

    if (handler != null)
    {
        int begin = element.getStartOffset();
        int end = element.getEndOffset();
        String string = null;
        try
        {
            string = doc.getText(begin, end - begin);
        }
        catch (BadLocationException ex)
        {
            ex.printStackTrace();
        }

        if (string == null) return;

        handler.execute(this, doc, string, begin, end, element);
    }
}
项目:TrabalhoFinalEDA2    文件:mxGraphComponent.java   
/**
 * installs a handler to set the focus to the container.
 */
protected void installFocusHandler()
{
    graphControl.addMouseListener(new MouseAdapter()
    {
        public void mousePressed(MouseEvent e)
        {
            if (!hasFocus())
            {
                requestFocus();
            }
        }
    });
}
项目:zencash-swing-wallet-ui    文件:AddressBookPanel.java   
@Override
public void mousePressed(MouseEvent e) {
    if (e.isConsumed() || (!e.isPopupTrigger()))
        return;

    int row = table.rowAtPoint(e.getPoint());
    int column = table.columnAtPoint(e.getPoint());
    table.changeSelection(row, column, false, false);
    AddressBookEntry entry = entries.get(row);

    JPopupMenu menu = new JPopupMenu();

    JMenuItem sendCash = new JMenuItem("Send ZEN to "+entry.name);
    sendCash.addActionListener(new SendCashActionListener());
    menu.add(sendCash);

    JMenuItem copyAddress = new JMenuItem("Copy address to clipboard");
    copyAddress.addActionListener(new CopyToClipboardActionListener());
    menu.add(copyAddress);

    JMenuItem deleteEntry = new JMenuItem("Delete "+entry.name+" from contacts");
    deleteEntry.addActionListener(new DeleteAddressActionListener());
    menu.add(deleteEntry);

    menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
    e.consume();
}
项目:jaer    文件:HumanVsComputerThrottleController.java   
private Point getPixel(MouseEvent e) {
    if (canvas == null) {
        return null;
    }
    Point p = canvas.getPixelFromMouseEvent(e);
    if (canvas.wasMousePixelInsideChipBounds()) {
        return p;
    } else {
        return null;
    }
}
项目:openjdk-jdk10    文件:MouseEventDriver.java   
@Override
public void clickMouse(ComponentOperator oper, int x, int y, int clickCount, int mouseButton,
        int modifiers, Timeout mouseClick) {

    moveMouse(oper, x, y);
    dispatchEvent(oper.getSource(),
            MouseEvent.MOUSE_ENTERED,
            0, x, y, 0,
            Operator.getDefaultMouseButton());
    dispatchEvent(oper.getSource(),
            MouseEvent.MOUSE_PRESSED,
            modifiers, x, y, 1,
            mouseButton);

    for (int i = 1; i < clickCount; i++) {
        dispatchEvent(oper.getSource(),
                MouseEvent.MOUSE_RELEASED,
                modifiers, x, y, i,
                mouseButton);
        dispatchEvent(oper.getSource(),
                MouseEvent.MOUSE_CLICKED,
                modifiers, x, y, i,
                mouseButton);
        dispatchEvent(oper.getSource(),
                MouseEvent.MOUSE_PRESSED,
                modifiers, x, y, i + 1,
                mouseButton);
    }

    mouseClick.sleep();
    dispatchEvent(oper.getSource(),
            MouseEvent.MOUSE_RELEASED,
            modifiers, x, y, clickCount,
            mouseButton);
    dispatchEvent(oper.getSource(),
            MouseEvent.MOUSE_CLICKED,
            modifiers, x, y, clickCount,
            mouseButton);
    exitMouse(oper);
}
项目:openjdk-jdk10    文件:WMouseDragGestureRecognizer.java   
/**
 * Invoked when a mouse button has been pressed on a component.
 */

@Override
public void mousePressed(MouseEvent e) {
    events.clear();

    if (mapDragOperationFromModifiers(e) != DnDConstants.ACTION_NONE) {
        try {
            motionThreshold = DragSource.getDragThreshold();
        } catch (Exception exc) {
            motionThreshold = 5;
        }
        appendEvent(e);
    }
}
项目:incubator-netbeans    文件:JExtendedTree.java   
public void processMouseEvent(MouseEvent e) {
    if (e instanceof MouseWheelEvent) {
        Component target = JExtendedTree.this.getParent();
        if (target == null || !(target instanceof JViewport))
            target = JExtendedTree.this;
        MouseEvent mwe = SwingUtilities.convertMouseEvent(
                JExtendedTree.this, (MouseWheelEvent)e, target);
        target.dispatchEvent((MouseWheelEvent)mwe);
    } else {
        super.processMouseEvent((MouseEvent)e);
    }
}
项目:openjdk-jdk10    文件:MotifDnDDropTargetProtocol.java   
/**
 * Reset the state of the object.
 */
public void cleanup() {
    // Clear the reference to this protocol.
    XDropTargetEventProcessor.reset();

    if (targetXWindow != null) {
        notifyProtocolListener(targetXWindow, 0, 0,
                               DnDConstants.ACTION_NONE, sourceActions,
                               null, MouseEvent.MOUSE_EXITED);
    }

    if (sourceWindow != 0) {
        XToolkit.awtLock();
        try {
            XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
            XlibWrapper.XSelectInput(XToolkit.getDisplay(), sourceWindow,
                                     sourceWindowMask);
            XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
        } finally {
            XToolkit.awtUnlock();
        }
    }

    sourceWindow = 0;
    sourceWindowMask = 0;
    sourceProtocolVersion = 0;
    sourceActions = DnDConstants.ACTION_NONE;
    sourceFormats = null;
    sourceAtom = 0;
    userAction = DnDConstants.ACTION_NONE;
    sourceX = 0;
    sourceY = 0;
    targetXWindow = null;
    topLevelLeavePostponed = false;
}
项目:incubator-netbeans    文件:WatchAnnotationProvider.java   
@Override
public void mouseExited(MouseEvent e) {
    if (lastFocusOwner != null) {
        lastFocusOwner.removeKeyListener(this);
        lastFocusOwner = null;
    }
    unsetSelectCursor();
}
项目:jaer    文件:EventFilter2DMouseAdaptor.java   
/**
 * Returns the chip pixel position from the MouseEvent.
 * Note that any calls that modify the GL model matrix (or viewport, etc) will make the location meaningless.
 * Make sure that your graphics rendering code wraps transforms inside pushMatrix and popMatrix calls.
 *
 * @param e the mouse event
 * @return the pixel position in the chip object, origin 0,0 in lower left
 * corner.
 */
protected Point getMousePixel(MouseEvent e) {
    if (chipCanvas == null) {
        return null;
    }
    Point p = chipCanvas.getPixelFromMouseEvent(e);
    if (chipCanvas.wasMousePixelInsideChipBounds()) {
        return p;
    } else {
        return null;
    }
}
项目:myqq    文件:Login.java   
/**
 * 处理窗体的拖拽事件
 * @param e
 */
public void mouseDrag(MouseEvent e)
{
    Point point = e.getLocationOnScreen();
    int offsetX = point.x - lastPoint.x;
    int offsetY = point.y - lastPoint.y;
    Rectangle bounds = this.getBounds();
    bounds.x += offsetX;
    bounds.y += offsetY;
    this.setBounds(bounds);
    lastPoint = point;
}
项目:featurea    文件:Util.java   
public static InputSource retrieveInputSourceFromMouseEvent(MouseEvent mouseEvent) {
    if (mouseEvent instanceof MouseWheelEvent) {
        return InputSource.MOUSE_WHEEL;
    }
    if (SwingUtilities.isLeftMouseButton(mouseEvent)) {
        return InputSource.TOUCH;
    }
    if (SwingUtilities.isRightMouseButton(mouseEvent)) {
        return InputSource.MOUSE_RIGHT;
    }
    return InputSource.TOUCH; // IMPORTANT
}
项目:OpenJSharp    文件:NervousText.java   
@Override
public synchronized void mousePressed(MouseEvent e) {
    e.consume();
    threadSuspended = !threadSuspended;
    if (!threadSuspended) {
        notify();
    }
}
项目:alevin-svn2    文件:MultiAlgoScenarioWizard.java   
private void updateSelection(MouseEvent e) {
    int row = networkTable.rowAtPoint(e.getPoint());
    if (row < 0) {
        networkTable.clearSelection();
    } else {
        networkTable.setRowSelectionInterval(row, row);
    }
}
项目:JavaGraph    文件:PropertiesDisplay.java   
@Override
public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2) {
        getActions().getEditSystemPropertiesAction()
            .execute();
    }
}
项目:QN-ACTR-Release    文件:KMeanSingleClusterScatter.java   
public void mousePressed(MouseEvent e) {
    // Controllo che la pressione del mouse risulti all'interno dell'area del grafico
    if ((e.getX() - UpperLeftGraph.x) >= 0 && (e.getY() - UpperLeftGraph.y) >= 0
            && (e.getX() - UpperLeftGraph.x) < KMeanSingleClusterScatter.this.WIDTH
            && (e.getY() - UpperLeftGraph.y) < KMeanSingleClusterScatter.this.HEIGHT) {
        // Start visualizzazione zoom area
        if (e.getButton() == MouseEvent.BUTTON1) {
            xStart = e.getX();
            yStart = e.getY();
            zoomming = true;
        }
    }
}
项目:Equella    文件:FlatterCheckBoxUI.java   
@Override
public synchronized void mousePressed(MouseEvent e)
{
    JComponent c = (JComponent) e.getComponent();
    if( c.isEnabled() )
    {
        c.setForeground(mTextPressed);
        c.setBackground(mBackgroundPressed);
        c.repaint();
    }
}
项目:openjdk-jdk10    文件:MissingDragExitEventTest.java   
@Override
public void mouseExited(final MouseEvent e) {
    if (!inside) {
        FAILED = true;
        Thread.dumpStack();
    }
    inside = false;
    MOUSE_EXIT = true;
}
项目:incubator-netbeans    文件:MultiSplitPane.java   
@Override
public void mouseReleased(MouseEvent e) {
    if( null == draggingDivider )
        return;

    final Point p = new Point( e.getPoint() );
    draggingDivider.finishDraggingTo( p );
    draggingDivider = null;
    setCursor( Cursor.getDefaultCursor() );
    e.consume();
}
项目:incubator-netbeans    文件:ListView.java   
@Override
public void mouseClicked(MouseEvent e) {
    if (MouseUtils.isDoubleClick(e)) {
        int index = list.locationToIndex(e.getPoint());
        performObjectAt(index, e.getModifiers());
    }
}
项目:rapidminer    文件:Item.java   
public void componentMouseReleased(MouseEvent e) {
    if (this.parentPane.getFilePane().isAutoArrange()) {
        this.setLocation(this.initPosition);
    } else {
        return;
    }
}
项目:jmt    文件:UpdatePanel.java   
@Override
public String getToolTipText(MouseEvent e) {
    String tip = null;
    Point p = e.getPoint();
    int rowIndex = rowAtPoint(p);
    try {
        tip = data.get(rowIndex).getToolTip();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    return tip;
}
项目:Cognizant-Intelligent-Test-Scripter    文件:Listeners.java   
@Override
public void mouseEntered(MouseEvent e) {
    JButton now = (JButton) e.getSource();
    if (!now.isSelected()) {
        now.setBorder(focusBorder);
    }
}
项目:incubator-netbeans    文件:MultiSplitPane.java   
@Override
public void mousePressed(MouseEvent e) {
    if( !Switches.isTopComponentResizingEnabled() )
        return;
    doLayout();
    MultiSplitDivider divider = dividerAtPoint( e.getPoint() );
    if( null == divider )
        return;

    draggingDivider = divider;
    divider.startDragging( e.getPoint() );
    e.consume();
}
项目:incubator-netbeans    文件:ProfilerTableHover.java   
public void mouseMoved(MouseEvent e) {
    // Do not display popup when a modifier is pressed (can't read all keys)
    if (e.getModifiers() != 0) return;

    Point point = e.getPoint();
    // Skip AWT noise after closing popup
    if (point.equals(forwardPoint)) return;

    checkPopup(table.rowAtPoint(point), table.columnAtPoint(point), point);
}
项目:incubator-netbeans    文件:ButtonPopupSwitcher.java   
@Override
public void mouseMoved(MouseEvent e) {
    e.consume();
    changeSelection(e);
    pTable.onMouseEvent(e);
    isDragging = false;
}
项目:incubator-netbeans    文件:HintsPanelLogic.java   
@Override
public void mouseClicked(MouseEvent e) {
    Point p = e.getPoint();
    TreePath path = errorTree.getPathForLocation(e.getPoint().x, e.getPoint().y);
    if ( path != null ) {
        Rectangle r = errorTree.getPathBounds(path);
        if (r != null) {
            r.width = r.height;
            if ( r.contains(p)) {
                toggle( path );
            }
        }
    }
}
项目:TopDownGame    文件:ControlMouse.java   
@Override
public void mouseClicked(MouseEvent e)
{

}
项目:openjdk-jdk10    文件:DrawTest.java   
@Override
public void mouseClicked(MouseEvent e) {
}
项目:Logisim    文件:Canvas.java   
@Override
protected void processMouseMotionEvent(MouseEvent e) {
    repairMouseEvent(e);
    super.processMouseMotionEvent(e);
}
项目:incubator-netbeans    文件:SnippetPanel.java   
public void mouseEntered(MouseEvent e) {
    title.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    title.setRollOver(true);
}