本文整理匯總了Java中java.awt.event.MouseEvent.getButton方法的典型用法代碼示例。如果您正苦於以下問題:Java MouseEvent.getButton方法的具體用法?Java MouseEvent.getButton怎麽用?Java MouseEvent.getButton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.event.MouseEvent
的用法示例。
在下文中一共展示了MouseEvent.getButton方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mousePressed
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
@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());
}
}
示例2: mouseReleased
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
@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));
}
}
示例3: mouseClicked
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
@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);
}
}
示例4: mouseClicked
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
@Override
public void mouseClicked(MouseEvent e) {
if (e.isPopupTrigger()) {
return;
}
e.consume();
int position = editorPane.viewToModel(e.getPoint());
if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON1) {
if (position < 0) {
return;
}
if (mousedIndex != -1) {
selectedIndex = mousedIndex;
releaseUI(true);
return;
}
}
try {
int line = Utilities.getLineOffset((BaseDocument) doc, position) + 1;
if (line < startLine || line > endLine) {
releaseUI(false);
return;
}
} catch (BadLocationException ex) {
}
}
示例5: isRightMouseButton
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
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;
}
示例6: mousePressed
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
@Override
public void mousePressed(MouseEvent e){
if(e.getButton() == MouseEvent.BUTTON1 &&
new Ellipse2D.Double(0.0, 0.0, region.width, region.height).contains(e.getPoint())){
isPressed = true;
repaint();
fireActionPerformed(new ActionEvent(thisButton, 0, null));
}
}
示例7: mouseClicked
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
/**
* Invoked when mouse is clicked on the graph
* @param ev the click event
*/
public void mouseClicked(MouseEvent ev) {
if (ev.getButton() == MouseEvent.BUTTON1) {
leftClick(ev);
} else if (ev.getButton() == MouseEvent.BUTTON3) {
rightClick(ev);
} else {
repaint();
}
}
示例8: mouseDragged
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
/**
*
*/
public void mouseDragged(MouseEvent e) {
if (!e.isConsumed() && graphComponent.isEnabled() && isEnabled()) {
// Activates the handler
if (!active && first != null) {
double dx = Math.abs(first.getX() - e.getX());
double dy = Math.abs(first.getY() - e.getY());
int tol = graphComponent.getTolerance();
if (dx > tol || dy > tol) {
active = true;
}
}
if (e.getButton() == 0 || (isActive() && connectPreview.isActive())) {
mxCellState state = marker.process(e);
if (connectPreview.isActive()) {
connectPreview.update(e, marker.getValidState(), e.getX(), e.getY());
setBounds(null);
e.consume();
} else {
source = state;
}
}
}
}
示例9: dragStarted
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
@Override
public void dragStarted(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1 && e.getSource() instanceof JLayeredPane) {
selectionContainer = new JNodeContainerSelection(e.getPoint());
add(selectionContainer, JLayeredPane.POPUP_LAYER);
}
}
示例10: mousePressed
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
public void mousePressed(MouseEvent e) {
Topology tp = node.getTopology();
if (((JTopology) getParent()).handler.ctrlPressed) {
if (e.getButton() == 1)
tp.selectNode(node);
} else {
currentButton = e.getButton();
tp.setProperty("refreshMode", tp.getRefreshMode());
tp.setRefreshMode(Topology.RefreshMode.EVENTBASED);
}
}
示例11: mousePressed
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
/**
* {@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;
}
}
示例12: isLeftMouseButton
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
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;
}
示例13: mousePressed
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
@Override
public void mousePressed(MouseEvent e) {
if(e.getButton() == MouseEvent.BUTTON1) {
if(e.getClickCount() >= 2) {
int row = XMBeanAttributes.this.getSelectedRow();
int col = XMBeanAttributes.this.getSelectedColumn();
if(col != VALUE_COLUMN) return;
if(col == -1 || row == -1) return;
XMBeanAttributes.this.updateZoomedCell(row, col);
}
}
}
示例14: mouseReleased
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
@Override public void mouseReleased(MouseEvent me) {
if (me.getButton() == 1) { //left
mlbPressed = false;
mlbDown = false;
mlbReleased = true;
mlbRTime = -1;
}
else if(me.getButton() == 3) { //right
mrbPressed = false;
mrbDown = false;
mrbReleased = true;
mrbRTime = -1;
}
}
示例15: mouseClicked
import java.awt.event.MouseEvent; //導入方法依賴的package包/類
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
popup.show(p, e.getX(), e.getY());
}
}