当前位置: 首页>>代码示例>>Java>>正文


Java MouseEvent类代码示例

本文整理汇总了Java中java.awt.event.MouseEvent的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent类的具体用法?Java MouseEvent怎么用?Java MouseEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MouseEvent类属于java.awt.event包,在下文中一共展示了MouseEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: maybeShowPopup

import java.awt.event.MouseEvent; //导入依赖的package包/类
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());

	}
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:25,代码来源:HTMLEditor.java

示例2: initialize

import java.awt.event.MouseEvent; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:24,代码来源:CameraShot.java

示例3: mousePressed

import java.awt.event.MouseEvent; //导入依赖的package包/类
@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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:WorkflowTree.java

示例4: mouseReleased

import java.awt.event.MouseEvent; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:32,代码来源:Map.java

示例5: handlePopup

import java.awt.event.MouseEvent; //导入依赖的package包/类
@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());              
               }
           }
       }
   }
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:22,代码来源:PopupMousePlugin.java

示例6: mouseMoved

import java.awt.event.MouseEvent; //导入依赖的package包/类
@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();
}
 
开发者ID:DevonCrawford,项目名称:A-Pathfinding-Visualization,代码行数:17,代码来源:Frame.java

示例7: mousePressed

import java.awt.event.MouseEvent; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:13,代码来源:PanelController.java

示例8: mouseDragged

import java.awt.event.MouseEvent; //导入依赖的package包/类
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) {}
}
 
开发者ID:ritcat14,项目名称:The-Mysterious-Mind-Of-Jack,代码行数:16,代码来源:Mouse.java

示例9: mousePressed

import java.awt.event.MouseEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:29,代码来源:RuleTree.java

示例10: onContentMouseReleasedEvent

import java.awt.event.MouseEvent; //导入依赖的package包/类
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);
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:33,代码来源:Console.java

示例11: installFocusHandler

import java.awt.event.MouseEvent; //导入依赖的package包/类
/**
 * 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();
			}
		}
	});
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:17,代码来源:mxGraphComponent.java

示例12: mousePressed

import java.awt.event.MouseEvent; //导入依赖的package包/类
@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();
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:28,代码来源:AddressBookPanel.java

示例13: getPixel

import java.awt.event.MouseEvent; //导入依赖的package包/类
private Point getPixel(MouseEvent e) {
    if (canvas == null) {
        return null;
    }
    Point p = canvas.getPixelFromMouseEvent(e);
    if (canvas.wasMousePixelInsideChipBounds()) {
        return p;
    } else {
        return null;
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:12,代码来源:HumanVsComputerThrottleController.java

示例14: clickMouse

import java.awt.event.MouseEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:MouseEventDriver.java

示例15: mousePressed

import java.awt.event.MouseEvent; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:WMouseDragGestureRecognizer.java


注:本文中的java.awt.event.MouseEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。