本文整理汇总了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);
}
示例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()));
}
示例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");
}
}
示例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..");
}
示例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());
}
}
示例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());
}
}
示例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;
}
}
}
示例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;
}
}
示例9: mouseReleased
protected void mouseReleased(MouseEvent e)
{
if(e.getButton() == MouseEvent.BUTTON1)
{
dragging = false;
}
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
}
}
示例15: mouseClicked
@Override protected void mouseClicked(MouseEvent me) {
if (me.getButton() == MouseEvent.BUTTON1 && isMenuShortcutKeyDown(me) || ((JTable)component).isEditing()) {
return;
}
recorder.recordClick2(this, me, true);
}