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


Java MouseEvent.BUTTON2属性代码示例

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


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

示例1: isRightMouseButton

static boolean isRightMouseButton(MouseEvent me) {
    int numButtons = ((Integer)getDefaultToolkit().getDesktopProperty("awt.mouse.numButtons")).intValue();
    switch (me.getID()) {
      case MouseEvent.MOUSE_PRESSED:
      case MouseEvent.MOUSE_RELEASED:
          return ((numButtons == 2 && me.getButton() == MouseEvent.BUTTON2) ||
                   (numButtons > 2 && me.getButton() == MouseEvent.BUTTON3));
      case MouseEvent.MOUSE_ENTERED:
      case MouseEvent.MOUSE_EXITED:
      case MouseEvent.MOUSE_CLICKED:
      case MouseEvent.MOUSE_DRAGGED:
          return ((numButtons == 2 && (me.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) ||
                  (numButtons > 2 && (me.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0));
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:XToolkit.java

示例2: mouseReleased

@Override
public void mouseReleased(MouseEvent e) {
	int button = e.getButton();
	if (list.getSelectedIndices().length <= 1) {
		// If not left-click, enforce selection at the given location
		if (button != MouseEvent.BUTTON1) {
			int index = list.locationToIndex(e.getPoint());
			list.setSelectedIndex(index);
		}
	}
	Object value = list.getSelectedValue();
	if (value == null) {
		return;
	}
	if (button == MouseEvent.BUTTON3) {
		createContextMenu((AbstractInsnNode) value, e.getX(), e.getY());
	} else if (button == MouseEvent.BUTTON2) {
		createEdit((AbstractInsnNode) value, e.getX(), e.getY());
	}
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:20,代码来源:OpcodeMouseListener.java

示例3: mouseReleased

@Override
public void mouseReleased(MouseEvent e) {
	if ((e.getButton() == MouseEvent.BUTTON1 && viewport.zoomButtonVisible
			&& AutoZoomButtonClicked(viewport.getSize(), e.getX() * getZoomFactor() - getHorizzontalScrollBar(),
					e.getY() * getZoomFactor() - getVerticalScrollBar())
			&& viewport.zoomButtonColor != defaultzoomButtonColor)
			|| e.getButton() == MouseEvent.BUTTON2 && e.getClickCount() == 2) {
		autoZoomCenter();
	} else {
		if (drag_tool != null) {
			drag_tool.mouseReleased(Canvas.this, getGraphics(), e);
			drag_tool = null;
		}

		Tool tool = proj.getTool();
		if (tool != null) {
			tool.mouseMoved(Canvas.this, getGraphics(), e);
			setCursor(tool.getCursor());
		}
		completeAction();
	}
	viewport.zoomButtonColor = defaultzoomButtonColor;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:23,代码来源:Canvas.java

示例4: mouseReleased

public void mouseReleased(MouseEvent evt) {
	switch (evt.getButton()) {
	case MouseEvent.BUTTON1: {
		mouseLeft = false;
		break;
	}
	case MouseEvent.BUTTON2: {
		mouseRight = false;
		break;
	}
	}
	if (!mouseLeft && !mouseRight) {
		mouseMode = MouseMode.NONE;
	}
	// This is the last mouse action, so keep track of it.
	mouseEnd.x = evt.getX();
	mouseEnd.y = evt.getY();
	mouseDelta = new Point(mouseEnd.x - mouseStart.x, mouseEnd.y
			- mouseStart.y);
	repaint();
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:21,代码来源:Convex3DGraph.java

示例5: mouseReleased

@Override
public void mouseReleased(MouseEvent arg0) {
	if (arg0.getButton() == MouseEvent.BUTTON2 && arg0.getClickCount() == 1) {
		setCursor(cursor);
		this.mooving = false;
	} else if ((arg0.getButton() == MouseEvent.BUTTON1 && viewport.zoomButtonVisible
			&& com.cburch.logisim.gui.main.Canvas.AutoZoomButtonClicked(viewport.getSize(),
					arg0.getX() * getZoomFactor() - getHorizzontalScrollBar(),
					arg0.getY() * getZoomFactor() - getVerticalScrollBar())
			&& viewport.zoomButtonColor != com.cburch.logisim.gui.main.Canvas.defaultzoomButtonColor)
			|| arg0.getButton() == MouseEvent.BUTTON2 && arg0.getClickCount() == 2) {
		autoZoomCenter();
	}
	if (getTool() == null)
		setTool(tempTool);
	viewport.zoomButtonColor = com.cburch.logisim.gui.main.Canvas.defaultzoomButtonColor;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:17,代码来源:AppearanceCanvas.java

示例6: mouseReleased

@Override
public void mouseReleased(MouseEvent e)
{
	if(!inst.GAME_STARTED)
	{
		;
	}
	else
	{
		switch(e.getButton())
		{
			case MouseEvent.BUTTON1:
			{
				keys.MOUSE_LEFT = false;
				break;
			}
			case MouseEvent.BUTTON2:
			{
				keys.MOUSE_RIGHT = false;
				break;
			}
			case MouseEvent.BUTTON3:
			{
				break;
			}
		}
	}
}
 
开发者ID:ben-j-c,项目名称:TopDownGame,代码行数:28,代码来源:ControlMouse.java

示例7: mouseReleased

public void mouseReleased(MouseEvent e) {
    Topology tp = node.getTopology();
    if (tp.hasProperty("refreshMode"))
        tp.setRefreshMode((Topology.RefreshMode) tp.getProperty("refreshMode"));
    if (destination != null) {
        node.getTopology().addLink(new Link(node, destination));
        destination = null;
    } else {
        if (e.getButton() == MouseEvent.BUTTON3)
            node.getTopology().removeNode(node);
        else if (e.getButton() == MouseEvent.BUTTON2)
            node.getTopology().selectNode(node);
    }
    currentButton = 1;
}
 
开发者ID:acasteigts,项目名称:JBotSim,代码行数:15,代码来源:JNode.java

示例8: mousePressed

@Override
public void mousePressed(MouseEvent event) {
	if(event.getButton() == MouseEvent.BUTTON1) {
		isPrimaryPressed = true;
		
	} else if(event.getButton() == MouseEvent.BUTTON2) {
		isMiddlePressed = true;
		
	} else if(event.getButton() == MouseEvent.BUTTON3) {
		isSecondaryPressed = true;
	}
}
 
开发者ID:ProjectK47,项目名称:Mafia,代码行数:12,代码来源:MouseInput.java

示例9: mousePressed

public State mousePressed (Widget widget, WidgetMouseEvent event) {
    if (isLocked()) {
        return State.createLocked(widget, this);
    }
    
    Point localLocation = event.getPoint();
    
    if (event.getButton() == MouseEvent.BUTTON1 || event.getButton() == MouseEvent.BUTTON2) {
        invertSelection = (event.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0;
        
        if (provider.isSelectionAllowed(widget, localLocation, invertSelection)) {
            aiming = provider.isAimingAllowed(widget, localLocation, invertSelection);
            if (aiming) {
                updateState(widget, localLocation);
                return State.createLocked(widget, this);
            } else {
                provider.select(widget, localLocation, invertSelection);
                return State.CHAIN_ONLY;
            }
        }
    } else if (trapRightClick && event.getButton() == MouseEvent.BUTTON3) {
        provider.select(widget, localLocation, false);
        return State.CHAIN_ONLY;
    }
    
    return State.REJECTED;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:SelectAction.java

示例10: mousePressed

public State mousePressed (Widget widget, WidgetMouseEvent event) {
    if (event.getButton () == MouseEvent.BUTTON1 || event.getButton () == MouseEvent.BUTTON2) {
        stateModel.toggleBooleanState ();
        return State.CONSUMED;
    }
    return State.REJECTED;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:VMDNodeWidget.java

示例11: mouseClicked

@Override
public void mouseClicked(MouseEvent e) {
    // no operation
    if( e.getButton() == MouseEvent.BUTTON2 ) {
        slideBar.userMiddleClickedSlidingButton(e.getComponent());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:SlideGestureRecognizer.java

示例12: mousePressed

@Override
public State mousePressed(Widget widget, WidgetMouseEvent event) {
    if (event.getClickCount() == 1) {
        if (event.getButton() == MouseEvent.BUTTON1 || event.getButton() == MouseEvent.BUTTON2) {
            addNode("node" + nodeCounter++).setPreferredLocation(widget.convertLocalToScene(event.getPoint()));
            return State.CONSUMED;
        }
    }
    return State.REJECTED;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:Utils.java

示例13: storeMouseDown

private void storeMouseDown(int button) {
    if (button == MouseEvent.BUTTON1) {
        button1Pressed = true;
    }
    if (button == MouseEvent.BUTTON2) {
        button2Pressed = true;
    }
    if (button == MouseEvent.BUTTON3) {
        button3Pressed = true;
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:11,代码来源:EventQueueDevice.java

示例14: getButtons

public int getButtons() {
    if (button1Pressed) {
        return MouseEvent.BUTTON1;
    }
    if (button2Pressed) {
        return MouseEvent.BUTTON2;
    }
    if (button3Pressed) {
        return MouseEvent.BUTTON3;
    }
    return 0;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:EventQueueDevice.java

示例15: mousePressed

/**
 * {@inheritDoc}
 */
public void mousePressed(MouseEvent e) {
    if (!e.getComponent().isEnabled()) return;

    final Tile tile = canvas.convertToMapTile(e.getX(), e.getY());
    final Unit unit = getGUI().getActiveUnit();
    final int me = (e.isPopupTrigger()) ? MouseEvent.BUTTON3
        : e.getButton();
    if (canvas.isGotoStarted()) canvas.stopGoto();
    switch (me) {
    case MouseEvent.BUTTON1: // Drag and selection
        // Enable dragging with button 1
        // @see CanvasMouseMotionListener#mouseDragged
        canvas.setDragPoint(e.getX(), e.getY());
        canvas.requestFocus();
        break;
    case MouseEvent.BUTTON2: // Immediate goto
        if (tile != null && unit != null) {
            canvas.startGoto();
            getGUI().updateGotoPath(tile);
            getGUI().traverseGotoPath();
        }
        break;
    case MouseEvent.BUTTON3: // Immediate tile popup
        canvas.showTilePopup(tile, e.getX(), e.getY());
        break;
    default:
        break;
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:32,代码来源:CanvasMouseListener.java


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