Java Code Examples for java.awt.event.MouseEvent.BUTTON3

The following are Jave code examples for showing how to use BUTTON3 of the java.awt.event.MouseEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Recaf   File: MemberNodeClickListener.java   View Source Code Vote up 6 votes
@Override
public void mouseReleased(MouseEvent e) {
	int button = e.getButton();
	// 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();
	// Middle-click to open editor
	// Right-click to open context menu
	if (value != null && button == MouseEvent.BUTTON2) {
		// TODO: Allow users to choose custom middle-click actions
		if (value instanceof FieldNode) {
			display.openDefinition((FieldNode) value);
		} else if (value instanceof MethodNode) {
			display.openOpcodes((MethodNode) value);
		}
	} else if (button == MouseEvent.BUTTON3) {
		createContextMenu(value, e.getX(), e.getY(), isMethodList(list));
	}
}
 
Example 2
Project: etomica   File: GraphMap.java   View Source Code Vote up 6 votes
private MouseListener getMouseClickedListener(final SVGContextMenu menu) {

    return new MouseAdapter() {

      @Override
      public void mouseClicked(MouseEvent e) {

        Point p = new Point(e.getPoint());
        SwingUtilities.convertPointToScreen(p, canvas);
        if (menu.isVisible()) {
          if (e.getButton() == MouseEvent.BUTTON3) {
            menu.setLocation(p);
            return;
          }
          else {
            menu.setVisible(false);
          }
        }
        if (e.getButton() == MouseEvent.BUTTON3) {
          menu.setLocation(p);
          menu.setVisible(true);
        }
      }
    };
  }
 
Example 3
Project: rapidminer   File: PlotterMouseHandler.java   View Source Code Vote up 6 votes
@Override
public void mouseClicked(MouseEvent e) {
	if (e.getButton() == MouseEvent.BUTTON1) {
		if (e.getClickCount() > 1) {
			String id = plotter.getIdForPos(e.getX(), e.getY());
			if (id != null) {
				ObjectVisualizer visualizer = ObjectVisualizerService.getVisualizerForObject(dataTable);
				visualizer.startVisualization(id);
			}
		}
	} else if (e.getButton() == MouseEvent.BUTTON3) {
		plotter.setDrawRange(-1, -1, -1, -1);
		pressStart = null;
		plotter.setDragBounds(-1, -1, -1, -1);
	}
}
 
Example 4
Project: Recaf   File: OpcodeMouseListener.java   View Source Code Vote up 6 votes
@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());
	}
}
 
Example 5
Project: Spark   File: Java2DFrame.java   View Source Code Vote up 6 votes
public final void mousePressed(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_MOUSEDOWN,
			internalButton, e.getX(), e.getY()));
}
 
Example 6
Project: Java_GestionProjet   File: ActionClickDroit.java   View Source Code Vote up 6 votes
@Override
public void mouseClicked(MouseEvent e) {
	
	FenetreGestionDeProjet fenetre = FenetreGestionDeProjet.getInstance();
	
	// TODO Auto-generated method stub
	if (e.getButton() == MouseEvent.BUTTON3) {
		//System.out.println("modification et suppression");
		JMenu contextMenu = new JMenu();
		JMenuItem modifie = new JMenuItem("Modifier");
		JMenuItem supprime = new JMenuItem("Supprimer");
		contextMenu.add(modifie);
		contextMenu.add(supprime);
		contextMenu.setMenuLocation(e.getX(),e.getY());
		
		fenetre.add(contextMenu);

		contextMenu.setEnabled(true);
		contextMenu.setVisible(true);
		
		contextMenu.setPopupMenuVisible(true);
	}
}
 
Example 7
Project: incubator-netbeans   File: ContiguousSelectAction.java   View Source Code Vote up 5 votes
@Override
public State mousePressed (Widget widget, WidgetMouseEvent event) {
    Point localLocation = event.getPoint();
    if ((event.getButton() & (MouseEvent.BUTTON1  | MouseEvent.BUTTON2  | MouseEvent.BUTTON3)) != 0) {
        if (process (widget, localLocation, event.getModifiersEx ()))
            return State.CHAIN_ONLY;
    }
    return State.REJECTED;
}
 
Example 8
Project: incubator-netbeans   File: SelectAction.java   View Source Code Vote up 5 votes
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;
}
 
Example 9
Project: cc-unespar   File: Carimbo.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent e) {
	if(e.getButton() == MouseEvent.BUTTON1) {
		colar(e.getX(), e.getY());
		ImageIcon icone = new ImageIcon(img);
		background.setIcon(icone);
	}else if(e.getButton() == MouseEvent.BUTTON3) {
		copiar(e.getX(), e.getY());
	}
}
 
Example 10
Project: jmt   File: DistributionDensityGraph.java   View Source Code Vote up 5 votes
public void mouseClicked(MouseEvent ev) {
	if (ev.getButton() == MouseEvent.BUTTON3) {
		rightClick(ev);
	} else {

	}
}
 
Example 11
Project: JavaGraph   File: RuleTree.java   View Source Code Vote up 5 votes
@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);
}
 
Example 12
Project: FreeCol   File: CanvasMouseListener.java   View Source Code Vote up 5 votes
/**
 * {@inheritDoc}
 */
public void mousePressed(MouseEvent e) {
    if (!e.getComponent().isEnabled()) return;

    final Tile tile = canvas.convertToMapTile(e.getX(), e.getY());
    final int me = (e.isPopupTrigger()) ? MouseEvent.BUTTON3
        : e.getButton();
    switch (me) {
    case MouseEvent.BUTTON1:
        // Record initial click point for purposes of dragging,
        // @see CanvasMouseMotionListener#mouseDragged.
        canvas.setDragPoint(e.getX(), e.getY());

        // New click sequence? Remember position to use when timer expires
        if (!doubleClickTimer.isRunning()) {
            centerX = e.getX();
            centerY = e.getY();
        }
        doubleClickTimer.start();
        canvas.requestFocus();
        break;
    case MouseEvent.BUTTON2:
        immediateGoto(tile);
        break;
    case MouseEvent.BUTTON3:
        immediatePopup(tile, e.getX(), e.getY());
        break;
    default:
        break;
    }
}
 
Example 13
Project: jmt   File: PerformanceIndices2DGraph.java   View Source Code Vote up 5 votes
public void mouseClicked(MouseEvent ev) {
	if (ev.getButton() == MouseEvent.BUTTON3) {
		super.rightClick(ev);
		return;
	}
	DPoint test = this.adjustMousePoint(ev.getX(), ev.getY());
	for (int i = 0; i < data.getStationNames().length; i++) {
		if (stationLabels[i] != null && stationLabels[i].contains(test)) {
			showStation[i] = !showStation[i];
			repaint();
		}
	}
}
 
Example 14
Project: PackagePlugin   File: MouseListener.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3) {
        jtc.requestFocus();
        showMenu(e.getX(), e.getY());
    }
}
 
Example 15
Project: cuttlefish   File: GraphMouseImpl.java   View Source Code Vote up 5 votes
public void mouseClicked(MouseEvent e) {
	Point2D p = e.getPoint();

	if (p == null)
		return;

	p = renderer.screenToWorld(p);

	if (e.getButton() == MouseEvent.BUTTON1 && mouseInMode(Mode.EDITING)) {
		// create a node
		isCreatingVertex = true;
		Vertex vertex = new Vertex();
		vertex.setPosition(p);
		UndoableAction action = new CreateVertexUndoableAction(
				networkPanel.getNetwork(), vertex);
		action.execute();
		UndoableControl.getController().actionExecuted(action);

	} else if (e.getButton() == MouseEvent.BUTTON3) {
		Vertex v = pickSupport.pickVertex(p);

		if (v != null) {
			new EditVertexMenu(v, networkPanel.getNetwork(), e).show();

		} else {
			Edge edge = pickSupport.pickEdge(p);

			if (edge != null) {
				new EditEdgeMenu(edge, networkPanel.getNetwork(), e).show();
			}
		}
	}
}
 
Example 16
Project: ScreenCut   File: ScreenCut.java   View Source Code Vote up 4 votes
public void mouseClicked(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3 && e.getClickCount() == 2) {//鼠标右键双击退出截图
        dispose();
    }
}
 
Example 17
Project: incubator-netbeans   File: GlassPane.java   View Source Code Vote up 4 votes
@Override
        public void mousePressed(MouseEvent e) {
            Point point = e.getPoint();
            draggingStart = point;
            boolean leftMousePressed = (e.getButton() == MouseEvent.BUTTON1);
            boolean rightMousePressed = (e.getButton() == MouseEvent.BUTTON3);
            if (leftMousePressed) {
                if (resizingMode == 0) {
                    focusedComponent = findComponent(point);
                    if (e.isPopupTrigger()) { // Mac
                        if (!selection.contains(focusedComponent)) {
                            setSelection(focusedComponent);
                        }
                        showPopupMenu(point);
                    } else  if (!e.isShiftDown()) { // shift adding to selection on mouse release
                        if (focusedComponent != null && ctrlOrCmdModifier(e)) {
                            Set<Component> newSelection = new HashSet<Component>();
                            newSelection.addAll(selection);
                            if (selection.contains(focusedComponent)) {
                                newSelection.remove(focusedComponent);
                            } else {
                                newSelection.add(focusedComponent);
                            }
                            setSelection(newSelection);
                        } else if (!selection.contains(focusedComponent)) {
                            setSelection(focusedComponent);
                        }
                    }
//                    // Column selection
//                    int column = findColumnHeader(point);
//                    if (column != -1) {
////                        selectedColumns.flip(column);
//                    }
//                    // Row selection
//                    int row = findRowHeader(point);
//                    if (row != -1) {
////                        selectedRows.flip(row);
//                    }
                } else {
                    // Resizing (start)
                    resizing = true;
                    requestFocusInWindow();
                    draggingRect = fromComponentPane(selectionResizingBounds(focusedComponent));
                    newGridX = gridInfo.getGridX(focusedComponent);
                    newGridY = gridInfo.getGridY(focusedComponent);
                    newGridHeight = gridInfo.getGridHeight(focusedComponent);
                    newGridWidth = gridInfo.getGridWidth(focusedComponent);
                    initSelFields();
                }
            } else if (rightMousePressed) {
                if (moving || resizing) {
                    moving = false;
                    resizing = false;
                    draggingStart = null;
                } else {
                    focusedComponent = findComponent(point);
                    if (!selection.contains(focusedComponent)) {
                        setSelection(focusedComponent);
                    }
                    if (e.isPopupTrigger()) { // Linux
                        showPopupMenu(point);
                    }
                }
            }
            repaint();
        }
 
Example 18
Project: QN-ACTR-Release   File: EnlargeQQPlotVarVar.java   View Source Code Vote up 4 votes
public void mouseClicked(MouseEvent e) {
	if (e.getButton() == MouseEvent.BUTTON3) {
		pop.show(EnlargeQQPlotVarVar.this, e.getX(), e.getY());
	}
}
 
Example 19
Project: QN-ACTR-Release   File: EnlargeQQPlot.java   View Source Code Vote up 4 votes
public void mouseClicked(MouseEvent e) {
	if (e.getButton() == MouseEvent.BUTTON3) {
		pop.show(EnlargeQQPlot.this, e.getX(), e.getY());
	}
}
 
Example 20
Project: s-store   File: MarkovViewer.java   View Source Code Vote up 4 votes
@Override
public void mouseClicked(MouseEvent e) {
    if(e.getButton() == MouseEvent.BUTTON3){
        ((JPopupMenu)(e.getSource())).setVisible(false);
    }
}