Java Code Examples for java.awt.event.MouseEvent#getButton()

The following examples show how to use java.awt.event.MouseEvent#getButton() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GrandExchangeInputListener.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public MouseEvent mouseClicked(MouseEvent e)
{
	// Check if left click + alt
	if (e.getButton() == MouseEvent.BUTTON1 && e.isAltDown())
	{
		final MenuEntry[] menuEntries = client.getMenuEntries();
		for (final MenuEntry menuEntry : menuEntries)
		{
			if (menuEntry.getOption().equals(SEARCH_GRAND_EXCHANGE))
			{
				search(Text.removeTags(menuEntry.getTarget()));
				e.consume();
				break;
			}
		}
	}

	return super.mouseClicked(e);
}
 
Example 2
Source File: ContentTabLabel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void execute(final MouseEvent e) {

  Optional<Runnable> first = myAdditionalIcons.stream().filter(icon -> mouseOverIcon(icon)).map(icon -> icon.getAction()).findFirst();

  if (first.isPresent()) {
    first.get().run();
    return;
  }

  selectContent();

  if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !myLayout.myDoubleClickActions.isEmpty()) {
    DataContext dataContext = DataManager.getInstance().getDataContext(ContentTabLabel.this);
    for (AnAction action : myLayout.myDoubleClickActions) {
      AnActionEvent event = AnActionEvent.createFromInputEvent(e, ActionPlaces.UNKNOWN, null, dataContext);
      if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
        ActionManagerEx.getInstanceEx().fireBeforeActionPerformed(action, dataContext, event);
        ActionUtil.performActionDumbAware(action, event);
      }
    }
  }
}
 
Example 3
Source File: SearchWidget.java    From javamoney-examples with Apache License 2.0 6 votes vote down vote up
@Override
public
void
mousePressed(MouseEvent event)
{
  if(event.getSource() == getLabels()[RIGHT_LABEL] && event.getButton() == BUTTON1)
  {
    // Icons are only displayed on the right when the text field has focus.
    if(getField().hasFocus() == true)
    {
      if(getLabels()[RIGHT_LABEL].getIcon() == SEARCH_CLEAR.getIcon())
      {
        getLabels()[RIGHT_LABEL].setIcon(SEARCH_CLEAR_PRESSED.getIcon());
      }
    }
  }
}
 
Example 4
Source File: RocLinesPanel.java    From rtg-tools with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void mouseReleased(MouseEvent e) {
  if (mIsDragging && e.getButton() == MouseEvent.BUTTON1) {
    final int deltaY = e.getYOnScreen() - mOriginalScreenY;
    final int newY = mOriginalY + deltaY;
    final Component[] components = getComponents();
    // Find new position for mPanel (it is currently at position 0 due to Z order)
    int i;
    for (i = 1; i < components.length; ++i) {
      if (components[i].getY() >= newY) {
        break;
      }
    }
    mPanel.setBorder(mBorder);
    remove(mPanel);
    add(mPanel, i - 1);
    updateCurves();
    mIsDragging = false;
  }
}
 
Example 5
Source File: ViewDragScrollListener.java    From openAGV with Apache License 2.0 6 votes vote down vote up
@Override
public void mouseReleased(MouseEvent evt) {
  if (dragIsSelected()) {
    return;
  }

  final OpenTCSDrawingView drawingView = scrollPane.getDrawingView();
  Figure fig = drawingView.findFigure(evt.getPoint());
  if (fig instanceof LabeledPointFigure) {
    createPossibleTransportOrder((LabeledPointFigure) fig, drawingView.getSelectedFigures());
  }
  pressedFigure = null;
  fMouseEndPoint.setLocation(drawingView.viewToDrawing(evt.getPoint()));
  if (evt.getButton() != 2) {
    showPositionStatus(true);
  }
  else {
    showPositionStatus(false);
  }
}
 
Example 6
Source File: XMBeanAttributes.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example 7
Source File: GOSwingEventConverter.java    From settlers-remake with MIT License 5 votes vote down vote up
@Override
public void mouseReleased(MouseEvent e) {
	UIPoint local = convertToLocal(e);
	if (e.getButton() == MouseEvent.BUTTON1) {
		endDraw(local);

	} else if (panWithButton3 && e.getButton() == MouseEvent.BUTTON3) {
		endPan(local);

	} else if (!panWithButton3 && e.getButton() == MouseEvent.BUTTON2) {
		endPan(local);
	}
}
 
Example 8
Source File: BiomesViewerFrame.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
    if (e.getButton() != MouseEvent.BUTTON1) {
        return;
    }
    selecting = true;
    selectionCorner1 = getTileLocation(e.getX(), e.getY());
    selectionCorner2 = null;
    imageViewer.setSelectedRectangleCorner1(null);
    imageViewer.setSelectedRectangleCorner2(null);
}
 
Example 9
Source File: XToolkit.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 10
Source File: DeleteNodeTool.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1) {
        Point p = fixEventPoint(e.getPoint());
        pressPoint = editor.getViewer().getCoordinatesAtPoint(p.x, p.y);
        overlay.setLeft(pressPoint.getX());
        overlay.setBottom(pressPoint.getY());
        editor.getViewer().addOverlay(overlay);
        editor.getViewer().repaint();
    }
}
 
Example 11
Source File: XMBeanAttributes.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example 12
Source File: Draw.java    From algs4 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method cannot be called directly.
 */
@Override
public void mousePressed(MouseEvent e) {
    synchronized (mouseLock) {
        mouseX = userX(e.getX());
        mouseY = userY(e.getY());
        isMousePressed = true;
    }
    if (e.getButton() == MouseEvent.BUTTON1) {
        for (DrawListener listener : listeners)
            listener.mousePressed(userX(e.getX()), userY(e.getY()));
    }

}
 
Example 13
Source File: RolloverButtonListener.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void mouseEntered(MouseEvent e) {
	this.stateTransitionTracker.turnOffModelChangeTracking();
	try {
		super.mouseEntered(e);
		this.isMouseInside = true;
		boolean isMouseDrag = (e.getButton() == MouseEvent.BUTTON1);
		if (!isMouseDrag) {
			this.button.getModel().setRollover(true);
		}
	} finally {
		this.stateTransitionTracker.onModelStateChanged();
	}
}
 
Example 14
Source File: DataElementPanel.java    From javamoney-examples with Apache License 2.0 5 votes vote down vote up
@Override
public
void
mouseClicked(MouseEvent event)
{
  if(event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2)
  {
    // Make sure the user double-clicked on an element.
    if(getChooser().getRowForLocation(event.getX(), event.getY()) != -1)
    {
      edit();
    }
  }
}
 
Example 15
Source File: XMBeanAttributes.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example 16
Source File: VerticalLinealComponent.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void mousePressed( final MouseEvent e ) {
  final int padding = (int) getPadding();
  if ( e.getX() < padding ) {
    return;
  }

  if ( e.getButton() == MouseEvent.BUTTON1 ) {
    guideLineIndex = getActiveGuideIndex( e );
    if ( guideLineIndex != -1 ) {
      setDraggedGuideLine( getLinealModel().getGuideLine( guideLineIndex ) );
    }
  }
}
 
Example 17
Source File: FrmMiniroadbook.java    From Course_Generator with GNU General Public License v3.0 5 votes vote down vote up
protected String ManageMemories(MouseEvent e, String memo) {
	if (datalist.data.isEmpty())
		return memo;
	int row = TableData.getSelectedRow();
	if (row < 0)
		return memo;

	// -- Left click
	if (e.getButton() == MouseEvent.BUTTON1) {
		int line = (int) datalist.data.get(row).getNum() - 1;
		if (line > track.data.size())
			return memo;

		String txt = memo;
		tfFormat.setText(txt);
		track.data.get(line).FmtLbMiniRoadbook = txt;
		datalist.data.get(row).FmtLbMiniRoadbook = txt;

		track.isModified = true;
		RefreshTableData();
		pnlProfil.Refresh();
	}
	// -- Right click
	else if (e.getButton() == MouseEvent.BUTTON3) {
		memo = tfFormat.getText();
		track.isModified = true;
		// RefreshTooltips();
	}
	return memo;
}
 
Example 18
Source File: MouseManager.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void checkExtraMouseButtons(MouseEvent mouseEvent)
{
	// Prevent extra mouse buttons from being passed into the client,
	// as it treats them all as left click
	int button = mouseEvent.getButton();
	if (button >= MOUSE_BUTTON_4 && runeLiteConfig.blockExtraMouseButtons())
	{
		mouseEvent.consume();
	}
}
 
Example 19
Source File: Ruler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1) {
        x = e.getX();
        y = e.getY();
    }
}
 
Example 20
Source File: QuerySelectorDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void mouseClicked( final MouseEvent e ) {
  if ( e.getClickCount() > 1 && e.getButton() == MouseEvent.BUTTON1 ) {
    setConfirmed( true );
    QuerySelectorDialog.this.dispose();
  }
}