當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。