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

The following examples show how to use java.awt.event.MouseEvent#getButton() . These examples are extracted from open source projects. 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
@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 2
@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 3
Source Project: javamoney-examples   File: SearchWidget.java    License: 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 Project: openAGV   File: ViewDragScrollListener.java    License: 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 5
Source Project: consulo   File: ContentTabLabel.java    License: 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 6
@Override
public void mousePressed(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1) {
        x = e.getX();
        y = e.getY();
    }
}
 
Example 7
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 8
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 9
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 10
@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 11
@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 12
@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 13
@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 Project: algs4   File: Draw.java    License: 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 15
@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
@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 17
Source Project: hottub   File: XToolkit.java    License: 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 18
@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 19
Source Project: settlers-remake   File: GOSwingEventConverter.java    License: 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 20
public void mouseClicked( final MouseEvent e ) {
  if ( e.getClickCount() > 1 && e.getButton() == MouseEvent.BUTTON1 ) {
    setConfirmed( true );
    QuerySelectorDialog.this.dispose();
  }
}