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


Java MouseEvent.BUTTON1属性代码示例

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


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

示例1: mousePressed

@Override protected void mousePressed(MouseEvent me) {
    // Ignore double clicks on non-leaf tree nodes
    if (me.getButton() == MouseEvent.BUTTON1 && me.getModifiersEx() == InputEvent.BUTTON1_DOWN_MASK) {
        if (me.getClickCount() == 1) {
            return;
        }
        TreePath path = ((JTree) component).getPathForRow(row);
        if (path != null) {
            Object lastPathComponent = path.getLastPathComponent();
            if (lastPathComponent instanceof TreeNode) {
                TreeNode node = (TreeNode) lastPathComponent;
                if (node.getChildCount() != 0) {
                    return;
                }
            }
        }
    }
    // Ignore Ctrl+Clicks used to select the nodes
    if (me.getButton() == MouseEvent.BUTTON1 && isMenuShortcutKeyDown(me)) {
        return;
    }
    if (me.getButton() != MouseEvent.BUTTON1) {
        focusLost(null);
    }
    super.mousePressed(me);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:26,代码来源:RTree.java

示例2: mouseReleased

public final void mouseReleased(MouseEvent e)
{
	int internalButton = 0;
	switch (e.getButton())
	{
		case MouseEvent.BUTTON1:
			internalButton = 0;
			break;
		case MouseEvent.BUTTON3:
			internalButton = 1;
			break;
		case MouseEvent.BUTTON2:
			internalButton = 2;
			break;
	}
	
	game.gameQueue.add(new MousePressEvent(SparkEvents.E_MOUSEUP,
			internalButton, e.getX(), e.getY()));
}
 
开发者ID:TheRemote,项目名称:Spark,代码行数:19,代码来源:Java2DFrame.java

示例3: setMovementMouseButton

/**
 * Sets the mouse button that is used for moving the map. Possible values are:
 * <ul>
 * <li>{@link MouseEvent#BUTTON1} (left mouse button)</li>
 * <li>{@link MouseEvent#BUTTON2} (middle mouse button)</li>
 * <li>{@link MouseEvent#BUTTON3} (right mouse button)</li>
 * </ul>
 *
 * @param movementMouseButton the mouse button that is used for moving the map
 */
public void setMovementMouseButton(int movementMouseButton) {
    this.movementMouseButton = movementMouseButton;
    switch (movementMouseButton) {
        case MouseEvent.BUTTON1:
            movementMouseButtonMask = MouseEvent.BUTTON1_DOWN_MASK;
            break;
        case MouseEvent.BUTTON2:
            movementMouseButtonMask = MouseEvent.BUTTON2_DOWN_MASK;
            break;
        case MouseEvent.BUTTON3:
            movementMouseButtonMask = MouseEvent.BUTTON3_DOWN_MASK;
            break;
        default:
            throw new RuntimeException("Unsupported button");
    }
}
 
开发者ID:berniejenny,项目名称:MapAnalyst,代码行数:26,代码来源:DefaultMapController.java

示例4: mouseClicked

@Override
        public void mouseClicked(MouseEvent e) {
            if (e.getSource() == bar) {
                handle.requestExplicitSelection();
//                markAsSelected(true);
            }
            if (e.getClickCount() > 1 && (e.getSource() == mainLabel || e.getSource() == dynaLabel)) {
                handle.requestView();
            }
            if (e.getButton() != MouseEvent.BUTTON1) {
                showMenu(e);
            } else {
                ListComponent.this.requestFocus();
            }
            
//            System.out.println("list component requesting focus..");
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ListComponent.java

示例5: 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

示例6: mousePressed

@Override
public void mousePressed(MouseEvent e) {
    // we only want to select/deselect on left click, not middle click used during drag or something like that
    if (e.getButton() != MouseEvent.BUTTON1) {
        return;
    }
    // get global selection object for this map
    IPogamutEnvironments environments = Lookup.getDefault().lookup(IPogamutEnvironments.class);
    if (environments == null) {
        return;
    }
    IUnrealMap map = mapRenderer.getObject();

    EnvironmentSelection mapSelection = environments.getEnvironmentSelection(map);

    // Get list of selected bots
    Set<IRenderableUTAgent> clickedBots = this.getAgentsAt(e.getPoint());

    mapSelection.clearSelection();
    
    for (IRenderableUTAgent selectedAgent : clickedBots) {
        mapSelection.addSelected(selectedAgent.getDataSource());
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:24,代码来源:SelectableMapGLPanel.java

示例7: mousePressed

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) < Scatter.this.WIDTH
			&& (e.getY() - UpperLeftGraph.y) < Scatter.this.HEIGHT) {
		// Start visualizzazione zoom area
		if (e.getButton() == MouseEvent.BUTTON1) {
			xStart = e.getX();
			yStart = e.getY();
			zoomming = true;
		}
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:12,代码来源:Scatter.java

示例8: mouseReleased

@Override
public void mouseReleased(MouseEvent arg0) {
	switch (arg0.getButton()) {
	case MouseEvent.BUTTON1:
		game.leftClick = false;
		break;
	case MouseEvent.BUTTON2: // fall through
	case MouseEvent.BUTTON3:
		game.rightClick = false;
		break;
	}
}
 
开发者ID:DreamBlocks,项目名称:DreamBlocks,代码行数:12,代码来源:AwtEventsHandler.java

示例9: mouseReleased

protected void mouseReleased(MouseEvent e)
{
    if(e.getButton() == MouseEvent.BUTTON1)
    {
        dragging = false;
    }
}
 
开发者ID:AutonomousCarProject,项目名称:AutonomousCar,代码行数:7,代码来源:DraggingWindow.java

示例10: mouseClicked

public void mouseClicked(MouseEvent e) {
    // hide the balloon by any click
    hide();
    if (e.getButton() == MouseEvent.BUTTON1) {
        ActionEvent aev = new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
                                          liveArguments.getActionCommand(),
                                          e.getWhen(), e.getModifiers());
        XToolkit.postEvent(XToolkit.targetToAppContext(aev.getSource()), aev);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:InfoWindow.java

示例11: isLeftMouseButton

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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:XToolkit.java

示例12: mouseReleased

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

示例13: capturarAlvoGritoDeGuerra

/**
 * Captura o alvo clicado logo após um evento grito de guerra ter sido
 * gerado
 *
 * @param component alvo clicado
 * @param evt evento do mouse
 */
private void capturarAlvoGritoDeGuerra(Component component, MouseEvent evt) {
    if (evt.getButton() == MouseEvent.BUTTON1) {
        String name = component != null ? component.toString() : "";
        if (name.contains(Values.TO_STRING_HEROI) || name.contains(Values.TO_STRING_LACAIO)) {
            setAlvoSelecionado(Partida.getIdLong(name));
        }
    } else {
        setAlvoSelecionado(ALVO_CANCEL);
    }
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:17,代码来源:PartidaView.java

示例14: mouseReleased

@Override
public void mouseReleased(MouseEvent e) {
	Point point = e.getPoint();

	//System.out.println("Original x, y " + point.getX() + " , " + point.getY());
	Point2D newPoint = new Point2D.Double(0, 0);
	clickTransform.transform(point, newPoint); 
	Position clickPosition = new Position(newPoint.getX(), newPoint.getY());
	//System.out.println("Transformed x, y " + newPoint.getX() + " , " + newPoint.getY());
	
	// only listens to left clicks
	if (e.getButton() == MouseEvent.BUTTON1) {
		// get the set of all objects and figure out if the user clicked inside an object
		Set<AbstractObject> allObjects = simulator.getAllObjects();
		Toroidal2DPhysics space = simulator.getSimulatedSpace();
		//System.out.println("Received a click at " + clickPosition);
		
		for (AbstractObject obj : allObjects) {
			//System.out.println("Object " + obj + " distance to click " + space.findShortestDistance(clickPosition, obj.getPosition()) + " radius is " + obj.getRadius());
			if (space.findShortestDistance(clickPosition, obj.getPosition()) <= obj.getRadius()) {
				infoPanel.setClickedObject(obj);
				//System.out.println("Click matched object " + obj);
				return;
			}
		}
		
	}
}
 
开发者ID:CatherineHa,项目名称:Proj4,代码行数:28,代码来源:SpaceSettlersGUI.java

示例15: mouseClicked

@Override protected void mouseClicked(MouseEvent me) {
    if (me.getButton() == MouseEvent.BUTTON1 && isMenuShortcutKeyDown(me) || ((JTable)component).isEditing()) {
        return;
    }
    recorder.recordClick2(this, me, true);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:6,代码来源:RTable.java


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