Java Code Examples for java.awt.event.MouseEvent#MOUSE_CLICKED

The following examples show how to use java.awt.event.MouseEvent#MOUSE_CLICKED . 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: LoboBrowser   File: PermissionCellButton.java    License: MIT License 6 votes vote down vote up
@Override
protected void processMouseEvent(final MouseEvent e) {
  super.processMouseEvent(e);
  if (e.getID() == MouseEvent.MOUSE_ENTERED) {
    mouseIn = true;
    repaint();
  } else if (e.getID() == MouseEvent.MOUSE_EXITED) {
    mouseIn = false;
    repaint();
  } else if (e.getID() == MouseEvent.MOUSE_CLICKED) {
    assert (mouseIn);
    if (!permissionResult.isDefault && canBeUndecidable) {
      cell.setPermission(PermissionSystem.Permission.Undecided);
    } else {
      if (mouseOnLeft) {
        cell.setPermission(PermissionSystem.Permission.Deny);
      } else {
        cell.setPermission(PermissionSystem.Permission.Allow);
      }
    }
    cellChangeListener.onChange();
  } else {
    // System.out.println("Mouse event:" + e);
  }
}
 
Example 2
Source Project: pumpernickel   File: ClickSensitivityControl.java    License: MIT License 6 votes vote down vote up
@Override
public void eventDispatched(AWTEvent e) {
	MouseEvent m = (MouseEvent) e;
	if (m.getID() == MouseEvent.MOUSE_CLICKED) {
		mouseClicked(m);
	} else if (m.getID() == MouseEvent.MOUSE_DRAGGED) {
		mouseDragged(m);
	} else if (m.getID() == MouseEvent.MOUSE_ENTERED) {
		mouseEntered(m);
	} else if (m.getID() == MouseEvent.MOUSE_EXITED) {
		mouseExited(m);
	} else if (m.getID() == MouseEvent.MOUSE_MOVED) {
		mouseMoved(m);
	} else if (m.getID() == MouseEvent.MOUSE_PRESSED) {
		mousePressed(m);
	} else if (m.getID() == MouseEvent.MOUSE_RELEASED) {
		mouseReleased(m);
	}
}
 
Example 3
@EventHandler
public void handleLocateOnMapClick(MouseEvent event) {
    if (locateOnMapBounds != null && locateOnMapBounds.contains(event.getX() - getPosition().getX(), event.getY() - getPosition().getY())) {
        if (event.getID() == MouseEvent.MOUSE_PRESSED) {
            clicking = true;
            event.consume();
        } else if (event.getID() == MouseEvent.MOUSE_CLICKED) {
            if (currentMarker != null) {
                currentMarker.moveTo();
            } else {
                NotificationsUtil.showNotification("Clue Scroll", "No map marker found");
            }
            event.consume();
        } else {
            hovered = true;
            clicking = false;
            event.consume();
        }
    } else {
        clicking = false;
        hovered = false;
    }
}
 
Example 4
@EventHandler
public void handleReset(MouseEvent event) {
    if (resetBounds != null && resetBounds.contains(event.getX() - getPosition().getX(), event.getY() - getPosition().getY())) {
        if (event.getID() == MouseEvent.MOUSE_PRESSED) {
            clicking = true;
            event.consume();
        } else if (event.getID() == MouseEvent.MOUSE_CLICKED) {
            resetKills();
            event.consume();
        } else {
            hovered = true;
            clicking = false;
            event.consume();
        }
    } else {
        clicking = false;
        hovered = false;
    }
}
 
Example 5
Source Project: megamek   File: PicMap.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void processMouseEvent(MouseEvent e) {
    PMHotArea ha = getAreaUnder(e.getX(), e.getY());
    switch (e.getID()) {
        case MouseEvent.MOUSE_CLICKED:
            if (ha != null)
                ha.onMouseClick(e);
            break;
        case MouseEvent.MOUSE_PRESSED:
            if (ha != null)
                ha.onMouseDown(e);
            break;
        case MouseEvent.MOUSE_RELEASED:
            if (ha != null)
                ha.onMouseUp(e);
            break;
    }
    update();
}
 
Example 6
Source Project: consulo   File: IdeGlassPaneImpl.java    License: Apache License 2.0 6 votes vote down vote up
private static void fireMouseEvent(final MouseListener listener, final MouseEvent event) {
  switch (event.getID()) {
    case MouseEvent.MOUSE_PRESSED:
      listener.mousePressed(event);
      break;
    case MouseEvent.MOUSE_RELEASED:
      listener.mouseReleased(event);
      break;
    case MouseEvent.MOUSE_ENTERED:
      listener.mouseEntered(event);
      break;
    case MouseEvent.MOUSE_EXITED:
      listener.mouseExited(event);
      break;
    case MouseEvent.MOUSE_CLICKED:
      listener.mouseClicked(event);
      break;
  }
}
 
Example 7
Source Project: jdk8u-jdk   File: XToolkit.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 8
Source Project: jdk8u_jdk   File: XToolkit.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 9
Source Project: jdk8u-jdk   File: XToolkit.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 10
Source Project: netbeans   File: PopupUtil.java    License: Apache License 2.0 6 votes vote down vote up
public void eventDispatched(java.awt.AWTEvent aWTEvent) {
    if (aWTEvent instanceof MouseEvent) {
        MouseEvent mv = (MouseEvent)aWTEvent;
        if (mv.getID() == MouseEvent.MOUSE_CLICKED && mv.getClickCount() > 0) {
            //#118828
            if (! (aWTEvent.getSource() instanceof Component)) {
                hidePopup();
                return;
            }
            
            Component comp = (Component)aWTEvent.getSource();
            Container par = SwingUtilities.getAncestorNamed(POPUP_NAME, comp); //NOI18N
            // Container barpar = SwingUtilities.getAncestorOfClass(PopupUtil.class, comp);
            // if (par == null && barpar == null) {
            if ( par == null ) {
                hidePopup();
            }
        }
    }
}
 
Example 11
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 12
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}
 
Example 13
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}
 
Example 14
Source Project: consulo   File: OnePixelDivider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void processMouseEvent(MouseEvent e) {
  super.processMouseEvent(e);
  if (e.getID() == MouseEvent.MOUSE_CLICKED) {
    if (mySwitchOrientationEnabled
        && e.getClickCount() == 1
        && SwingUtilities.isLeftMouseButton(e) && (SystemInfo.isMac ? e.isMetaDown() : e.isControlDown())) {
      mySplitter.setOrientation(!mySplitter.getOrientation());
    }
    if (myResizeEnabled && e.getClickCount() == 2) {
      mySplitter.setProportion(.5f);
    }
  }
}
 
Example 15
Source Project: jdk8u60   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 16
Source Project: netbeans   File: Outline.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void processMouseEvent(MouseEvent e) {
    switch(e.getID()) {
      case MouseEvent.MOUSE_PRESSED:
          selectionDisabled = false;
          break;
      case MouseEvent.MOUSE_RELEASED:
          selectionDisabled = false;
          break;
      case MouseEvent.MOUSE_CLICKED:
          selectionDisabled = false;
          break;
      case MouseEvent.MOUSE_ENTERED:
          selectionDisabled = false;
          break;
      case MouseEvent.MOUSE_EXITED:
          selectionDisabled = false;
          break;
      case MouseEvent.MOUSE_MOVED:
          break;
      case MouseEvent.MOUSE_DRAGGED:
          if (selectionDisabled) {
              //System.err.println("\nDrag DISABLED.");
              return ;
          }
          break;
      case MouseEvent.MOUSE_WHEEL:
          break;
    }
    super.processMouseEvent(e);
}
 
Example 17
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
Source Project: jdk8u_jdk   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 19
Source Project: whyline   File: TimeUI.java    License: MIT License 4 votes vote down vote up
public boolean ioEventIsOfDesiredType(IOEvent io) {

		if(selection == null) return true;
		
		if(io instanceof MouseStateInputEvent) {

			MouseStateInputEvent mouseEvent = (MouseStateInputEvent)io;
			int id = mouseEvent.getType();
			
			switch(id) {
				case MouseEvent.MOUSE_PRESSED :
					return selection == press;
				case MouseEvent.MOUSE_DRAGGED :
					return selection == drag;
				case MouseEvent.MOUSE_CLICKED :
				case MouseEvent.MOUSE_RELEASED :
					return selection == release;
				case MouseEvent.MOUSE_WHEEL :
					return selection == scroll;
				case MouseEvent.MOUSE_MOVED :
					return selection == move;
				default :
					return false;
			}

		}
		else if(io instanceof KeyStateInputEvent) {
			
			KeyStateInputEvent keyEvent = (KeyStateInputEvent)io;
			int type = keyEvent.getType();
			
			switch(type) {
			case KeyEvent.KEY_PRESSED :
				return selection == keydown;
			case KeyEvent.KEY_RELEASED :
				return selection == keyup;
			case KeyEvent.KEY_TYPED :
				return selection == keyup;
			default:
				return false;
			}
			
		}
		else if(selection == repaint) return io instanceof GetGraphicsOutputEvent;
		else if(selection == print) return io instanceof TextualOutputEvent;
		
		else return false;
		
	}
 
Example 20
/**
 * This method is overridden so that if the user clicks in the line
 * number border, the caret is moved.<p>
 *
 * This method will ONLY work if LineNumberBorder is used
 * (not LineNumberList).
 *
 * @param event The mouse event.
 */
public void processMouseEvent(MouseEvent event) {
	if (event.getID() == MouseEvent.MOUSE_CLICKED) {
		int y = getViewport().getViewPosition().y + event.getY();
		int pos = editorPane.viewToModel(new Point(0, y));
		editorPane.setCaretPosition(pos);
	}
	super.processMouseEvent(event);
}