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

The following are Jave code examples for showing how to use MOUSE_RELEASED 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: incubator-netbeans   File: NbiTreeTable.java   View Source Code Vote up 6 votes
private void sendTreeHandleEvents(MouseEvent event) {
    int column = model.getTreeColumnIndex();
    int row = rowAtPoint(event.getPoint());
    
    MouseEvent mousePressed = new MouseEvent(treeRenderer,
            MouseEvent.MOUSE_PRESSED,
            event.getWhen(),
            event.getModifiers(),
            event.getX() - getCellRect(row, column, true).x,
            event.getY(),
            event.getClickCount(),
            event.isPopupTrigger());
    MouseEvent mouseReleased = new MouseEvent(treeRenderer,
            MouseEvent.MOUSE_RELEASED,
            event.getWhen(),
            event.getModifiers(),
            event.getX() - getCellRect(row, column, true).x,
            event.getY(),
            event.getClickCount(),
            event.isPopupTrigger());
    
    treeRenderer.dispatchEvent(mousePressed);
    treeRenderer.dispatchEvent(mouseReleased);
}
 
Example 2
Project: jdk8u-jdk   File: AquaMenuUI.java   View Source Code Vote up 6 votes
public void menuDragMouseDragged(final MenuDragMouseEvent e) {
    if (menuItem.isEnabled() == false) return;

    final MenuSelectionManager manager = e.getMenuSelectionManager();
    final MenuElement path[] = e.getPath();

    // In Aqua, we always respect the menu's delay, if one is set.
    // Doesn't matter how the menu is clicked on or otherwise moused over.
    final Point p = e.getPoint();
    if (p.x >= 0 && p.x < menuItem.getWidth() && p.y >= 0 && p.y < menuItem.getHeight()) {
        final JMenu menu = (JMenu)menuItem;
        final MenuElement selectedPath[] = manager.getSelectedPath();
        if (!(selectedPath.length > 0 && selectedPath[selectedPath.length - 1] == menu.getPopupMenu())) {
            if (menu.getDelay() == 0) {
                appendPath(path, menu.getPopupMenu());
            } else {
                manager.setSelectedPath(path);
                setupPostTimer(menu);
            }
        }
    } else if (e.getID() == MouseEvent.MOUSE_RELEASED) {
        final Component comp = manager.componentForPoint(e.getComponent(), e.getPoint());
        if (comp == null) manager.clearSelectedPath();
    }
}
 
Example 3
Project: openjdk-jdk10   File: XToolkit.java   View Source Code Vote up 6 votes
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 4
Project: VASSAL-src   File: Map.java   View Source Code Vote up 6 votes
public void drop(DropTargetDropEvent dtde) {
  if (dtde.getDropTargetContext().getComponent() == theMap) {
    final MouseEvent evt = new MouseEvent(
      theMap,
      MouseEvent.MOUSE_RELEASED,
      System.currentTimeMillis(),
      0,
      dtde.getLocation().x,
      dtde.getLocation().y,
      1,
      false
    );
    theMap.dispatchEvent(evt);
    dtde.dropComplete(true);
  }

  if (scroller.isRunning()) scroller.stop();
}
 
Example 5
Project: jdk8u-jdk   File: XToolkit.java   View Source Code Vote up 6 votes
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 6
Project: OpenJSharp   File: XToolkit.java   View Source Code Vote up 6 votes
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 7
Project: openjdk-jdk10   File: bug7146377.java   View Source Code Vote up 5 votes
private static String eventToString(MouseEvent e) {
    StringBuilder result = new StringBuilder();

    switch (e.getID()) {
        case MouseEvent.MOUSE_PRESSED:
            result.append("MOUSE_PRESSED");
            break;
        case MouseEvent.MOUSE_RELEASED:
            result.append("MOUSE_RELEASED");
            break;
        case MouseEvent.MOUSE_CLICKED:
            result.append("MOUSE_CLICKED");
            break;
        case MouseEvent.MOUSE_ENTERED:
            result.append("MOUSE_ENTERED");
            break;
        case MouseEvent.MOUSE_EXITED:
            result.append("MOUSE_EXITED");
            break;
        case MouseEvent.MOUSE_MOVED:
            result.append("MOUSE_MOVED");
            break;
        case MouseEvent.MOUSE_DRAGGED:
            result.append("MOUSE_DRAGGED");
            break;
        case MouseEvent.MOUSE_WHEEL:
            result.append("MOUSE_WHEEL");
            break;
        default:
            result.append("unknown type");
    }

    result.append(", modifiers = " + MouseEvent.getMouseModifiersText(e.getModifiers()));
    result.append(", modifiersEx = " + MouseEvent.getMouseModifiersText(e.getModifiersEx()));
    result.append(", button = " + e.getButton());

    return result.toString();
}
 
Example 8
Project: IntelliJ-Key-Promoter-X   File: KeyPromoter.java   View Source Code Vote up 5 votes
/**
 * Catches all UI events from the main IDEA AWT making it possible to inspect all mouse-clicks.
 * Note that on OSX this will not catch clicks on the (detached) menu bar.
 *
 * @param e event that is caught
 */
@Override
public void eventDispatched(AWTEvent e) {
    if (e.getID() == MouseEvent.MOUSE_RELEASED && ((MouseEvent) e).getButton() == MouseEvent.BUTTON1) {
        handleMouseEvent(e);
    }
}
 
Example 9
Project: incubator-netbeans   File: Outline.java   View Source Code Vote up 5 votes
@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 10
Project: incubator-netbeans   File: AbstractTabCellRenderer.java   View Source Code Vote up 5 votes
public String getCommandAtPoint(Point p, int tabState, Rectangle bounds, int mouseButton, int eventType, int modifiers) {
String result = null;
if (mouseButton == MouseEvent.BUTTON2 && eventType == MouseEvent.MOUSE_RELEASED) {
	result = TabDisplayer.COMMAND_CLOSE;
}
else {
	result = getCommandAtPoint (p, tabState, bounds);
}
      if (result != null) {
           if (TabDisplayer.COMMAND_SELECT == result) {
               boolean clipped = isClipLeft() || isClipRight();
               if ((clipped && eventType == MouseEvent.MOUSE_RELEASED && mouseButton == MouseEvent.BUTTON1) ||
                   (!clipped && eventType == MouseEvent.MOUSE_PRESSED && mouseButton == MouseEvent.BUTTON1)) {
                   
                   return result;
               }
           } else if (TabDisplayer.COMMAND_CLOSE == result && eventType == MouseEvent.MOUSE_RELEASED && isShowCloseButton()) {
               if ((modifiers & MouseEvent.SHIFT_DOWN_MASK) != 0) {
                   return TabDisplayer.COMMAND_CLOSE_ALL;
               } else if ((modifiers & MouseEvent.ALT_DOWN_MASK) != 0 && mouseButton != MouseEvent.BUTTON2) {
                   return TabDisplayer.COMMAND_CLOSE_ALL_BUT_THIS;
               } else if( ((tabState & TabState.CLOSE_BUTTON_ARMED) == 0 || (tabState & TabState.MOUSE_PRESSED_IN_CLOSE_BUTTON) == 0)
                       && mouseButton == MouseEvent.BUTTON1 )  {
                   //#208732
                   result = TabDisplayer.COMMAND_SELECT;
               }
               return result;
           }
      }
      return null;
  }
 
Example 11
Project: jdk8u-jdk   File: XToolkit.java   View Source Code Vote up 5 votes
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
Project: featurea   File: MouseStates.java   View Source Code Vote up 5 votes
public void eventDispatched(AWTEvent event) {
    if (event.getID() == MouseEvent.MOUSE_PRESSED) {
        isPressed = true;
        // System.out.println("[INFO] MouseStates isPressed: " + true);
    } else if (event.getID() == MouseEvent.MOUSE_RELEASED) {
        isPressed = false;
        // System.out.println("[INFO] MouseStates isPressed: " + false);
    }
}
 
Example 13
Project: marathonv5   File: RComponent.java   View Source Code Vote up 5 votes
public void processEvent(AWTEvent event) {
    setIndexOfType(super.getIndexOfType());
    if (event instanceof MouseEvent) {
        MouseEvent me = (MouseEvent) event;

        switch (me.getID()) {
        case MouseEvent.MOUSE_ENTERED:
            mouseEntered(me);
            break;
        case MouseEvent.MOUSE_PRESSED:
            mousePressed(me);
            break;
        case MouseEvent.MOUSE_RELEASED:
            mouseReleased(me);
            break;
        case MouseEvent.MOUSE_CLICKED:
            mouseClicked(me);
            break;
        case MouseEvent.MOUSE_EXITED:
            mouseExited(me);
            break;
        }
    } else if (event instanceof KeyEvent) {
        KeyEvent ke = (KeyEvent) event;
        switch (ke.getID()) {
        case KeyEvent.KEY_PRESSED:
            keyPressed(ke);
            break;
        case KeyEvent.KEY_RELEASED:
            keyReleased(ke);
            break;
        case KeyEvent.KEY_TYPED:
            keyTyped(ke);
            break;
        }
    }
}
 
Example 14
Project: jfrog-idea-plugin   File: MenuCheckbox.java   View Source Code Vote up 5 votes
@Override
protected void processMouseEvent(MouseEvent evt) {
    if (evt.getID() == MouseEvent.MOUSE_RELEASED && contains(evt.getPoint())) {
        doClick();
        setArmed(true);
        return;
    }
    super.processMouseEvent(evt);
}
 
Example 15
Project: OpenJSharp   File: XToolkit.java   View Source Code Vote up 5 votes
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
Project: jdk8u-jdk   File: XButtonPeer.java   View Source Code Vote up 4 votes
void handleJavaMouseEvent(MouseEvent e) {
    super.handleJavaMouseEvent(e);
    int id = e.getID();
    switch (id) {
      case MouseEvent.MOUSE_PRESSED:
          if (XToolkit.isLeftMouseButton(e) ) {
              Button b = (Button) e.getSource();

              if(b.contains(e.getX(), e.getY())) {
                  if (!isEnabled()) {
                      // Disabled buttons ignore all input...
                      return;
                  }
                  pressed = true;
                  armed = true;
                  repaint();
              }
          }

          break;

      case MouseEvent.MOUSE_RELEASED:
          if (XToolkit.isLeftMouseButton(e)) {
              if (armed)
              {
                  action(e.getWhen(),e.getModifiers());
              }
              pressed = false;
              armed = false;
              repaint();
          }

          break;

      case  MouseEvent.MOUSE_ENTERED:
          if (pressed)
              armed = true;
          break;
      case MouseEvent.MOUSE_EXITED:
          armed = false;
          break;
    }
}
 
Example 17
Project: incubator-netbeans   File: TreeTable.java   View Source Code Vote up 4 votes
/** Forwards mouse events to a renderer (tree).
 */
private void processMouseEvent(MouseEvent e) {
    if (shouldIgnore(e)) {
        return;
    }

    Point p = e.getPoint();
    int row = table.rowAtPoint(p);
    int column = table.columnAtPoint(p);

    // The autoscroller can generate drag events outside the Table's range. 
    if ((column == -1) || (row == -1)) {
        return;
    }

    // for automatic jemmy testing purposes
    if ((getEditingColumn() == column) && (getEditingRow() == row)) {
        return;
    }

    boolean changeSelection = true;

    if (isTreeColumn(column)) {
        TreePath path = tree.getPathForRow(TreeTable.this.rowAtPoint(e.getPoint()));
        Rectangle r = tree.getPathBounds(path);
 
        if ((e.getX() >= (r.x - positionX)) && (e.getX() <= (r.x - positionX + r.width))
            || isLocationInExpandControl( path, p )
            || e.getID() == MouseEvent.MOUSE_RELEASED || e.getID() == MouseEvent.MOUSE_CLICKED ) {
            changeSelection = false;
        }
    }

    if (table.getSelectionModel().isSelectedIndex(row) && e.isPopupTrigger()) {
        return;
    }

    if (table.editCellAt(row, column, e)) {
        setDispatchComponent(e);
        repostEvent(e);
    }

    if (e.getID() == MouseEvent.MOUSE_PRESSED) {
        table.requestFocus();
    }

    CellEditor editor = table.getCellEditor();

    if (changeSelection && ((editor == null) || editor.shouldSelectCell(e))) {
        setValueIsAdjusting(true);
        table.changeSelection(row, column, 
                Utilities.isMac() ? e.isMetaDown() : e.isControlDown(), //use META key on Mac to toggle selection
                e.isShiftDown());
        setValueIsAdjusting(false);
    }
}
 
Example 18
Project: incubator-netbeans   File: ProfilerTableHover.java   View Source Code Vote up 4 votes
private boolean isForwardEvent(MouseEvent e) {
    int eventID = e.getID();
    return eventID == MouseEvent.MOUSE_PRESSED ||
           eventID == MouseEvent.MOUSE_RELEASED ||
           eventID == MouseEvent.MOUSE_WHEEL;
}
 
Example 19
Project: openjdk-jdk10   File: XButtonPeer.java   View Source Code Vote up 4 votes
void handleJavaMouseEvent(MouseEvent e) {
    super.handleJavaMouseEvent(e);
    int id = e.getID();
    switch (id) {
      case MouseEvent.MOUSE_PRESSED:
          if (XToolkit.isLeftMouseButton(e) ) {
              Button b = (Button) e.getSource();

              if(b.contains(e.getX(), e.getY())) {
                  if (!isEnabled()) {
                      // Disabled buttons ignore all input...
                      return;
                  }
                  pressed = true;
                  armed = true;
                  repaint();
              }
          }

          break;

      case MouseEvent.MOUSE_RELEASED:
          if (XToolkit.isLeftMouseButton(e)) {
              if (armed)
              {
                  @SuppressWarnings("deprecation")
                  final int modifiers = e.getModifiers();
                  action(e.getWhen(), modifiers);
              }
              pressed = false;
              armed = false;
              repaint();
          }

          break;

      case  MouseEvent.MOUSE_ENTERED:
          if (pressed)
              armed = true;
          break;
      case MouseEvent.MOUSE_EXITED:
          armed = false;
          break;
    }
}
 
Example 20
Project: OpenJSharp   File: XButtonPeer.java   View Source Code Vote up 4 votes
void handleJavaMouseEvent(MouseEvent e) {
    super.handleJavaMouseEvent(e);
    int id = e.getID();
    switch (id) {
      case MouseEvent.MOUSE_PRESSED:
          if (XToolkit.isLeftMouseButton(e) ) {
              Button b = (Button) e.getSource();

              if(b.contains(e.getX(), e.getY())) {
                  if (!isEnabled()) {
                      // Disabled buttons ignore all input...
                      return;
                  }
                  pressed = true;
                  armed = true;
                  repaint();
              }
          }

          break;

      case MouseEvent.MOUSE_RELEASED:
          if (XToolkit.isLeftMouseButton(e)) {
              if (armed)
              {
                  action(e.getWhen(),e.getModifiers());
              }
              pressed = false;
              armed = false;
              repaint();
          }

          break;

      case  MouseEvent.MOUSE_ENTERED:
          if (pressed)
              armed = true;
          break;
      case MouseEvent.MOUSE_EXITED:
          armed = false;
          break;
    }
}