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

The following examples show how to use java.awt.event.MouseEvent#MOUSE_ENTERED . 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: CWarningWindow.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void notifyMouseEvent(int id, long when, int button, int x, int y,
                             int screenX, int screenY, int modifiers,
                             int clickCount, boolean popupTrigger,
                             byte[] bdata) {
    LWWindowPeer peer = ownerPeer.get();
    if (id == MouseEvent.MOUSE_EXITED) {
        if (peer != null) {
            peer.updateSecurityWarningVisibility();
        }
    } else if(id == MouseEvent.MOUSE_ENTERED) {
        if (peer != null) {
            peer.updateSecurityWarningVisibility();
        }
    }
}
 
Example 2
Source File: CWarningWindow.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void notifyMouseEvent(int id, long when, int button, int x, int y,
                             int screenX, int screenY, int modifiers,
                             int clickCount, boolean popupTrigger,
                             byte[] bdata) {
    LWWindowPeer peer = ownerPeer.get();
    if (id == MouseEvent.MOUSE_EXITED) {
        if (peer != null) {
            peer.updateSecurityWarningVisibility();
        }
    } else if(id == MouseEvent.MOUSE_ENTERED) {
        if (peer != null) {
            peer.updateSecurityWarningVisibility();
        }
    }
}
 
Example 3
Source File: XToolkit.java    From jdk8u-jdk with 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 4
Source File: CWarningWindow.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void notifyMouseEvent(int id, long when, int button, int x, int y,
                             int screenX, int screenY, int modifiers,
                             int clickCount, boolean popupTrigger,
                             byte[] bdata) {
    LWWindowPeer peer = ownerPeer.get();
    if (id == MouseEvent.MOUSE_EXITED) {
        if (peer != null) {
            peer.updateSecurityWarningVisibility();
        }
    } else if(id == MouseEvent.MOUSE_ENTERED) {
        if (peer != null) {
            peer.updateSecurityWarningVisibility();
        }
    }
}
 
Example 5
Source File: XToolkit.java    From TencentKona-8 with 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 6
Source File: XToolkit.java    From openjdk-8-source with 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 7
Source File: bug7146377.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: XToolkit.java    From jdk8u60 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 9
Source File: XToolkit.java    From openjdk-jdk9 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: XToolkit.java    From openjdk-jdk8u-backup 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 11
Source File: bug7146377.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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 12
Source File: bug7146377.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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 13
Source File: bug7146377.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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 14
Source File: EventDispatcher.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void eventDispatched(AWTEvent event) {
    if (event instanceof MouseEvent) {
        MouseEvent e = (MouseEvent) event;
        if (e.getID() == MouseEvent.MOUSE_ENTERED) {
            mouseComponent = e.getComponent();
        } else if (e.getID() == MouseEvent.MOUSE_EXITED) {
            mouseComponent = null;
        }
    }
}
 
Example 15
Source File: HelpTooltipManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void showTooltip(@Nonnull JComponent component, @Nonnull MouseEvent event) {
  initPopupBuilder(new HelpTooltip().setTitle(component.getToolTipText(event)));

  if (event.getID() == MouseEvent.MOUSE_ENTERED) {
    myMouseListener.mouseEntered(event);
  }
  else {
    myMouseListener.mouseMoved(event);
  }
}
 
Example 16
Source File: CPlatformResponder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handles mouse events.
 */
void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber,
                      int clickCount, int x, int y, int absX, int absY) {
    final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
    if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
            || buttonNumber > tk.getNumberOfButtons() - 1) {
        return;
    }

    int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
                                       NSEvent.nsToJavaEventType(eventType);

    int jbuttonNumber = MouseEvent.NOBUTTON;
    int jclickCount = 0;

    if (jeventType != MouseEvent.MOUSE_MOVED &&
        jeventType != MouseEvent.MOUSE_ENTERED &&
        jeventType != MouseEvent.MOUSE_EXITED)
    {
        jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
        jclickCount = clickCount;
    }

    int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);
    boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers);

    eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber,
            x, y, absX, absY, jmodifiers, jclickCount,
            jpopupTrigger, null);
}
 
Example 17
Source File: CPlatformResponder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handles mouse events.
 */
void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber,
                      int clickCount, int x, int y, int absoluteX,
                      int absoluteY) {
    final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
    if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
            || buttonNumber > tk.getNumberOfButtons() - 1) {
        return;
    }

    int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
                                       NSEvent.nsToJavaEventType(eventType);

    int jbuttonNumber = MouseEvent.NOBUTTON;
    int jclickCount = 0;

    if (jeventType != MouseEvent.MOUSE_MOVED &&
        jeventType != MouseEvent.MOUSE_ENTERED &&
        jeventType != MouseEvent.MOUSE_EXITED)
    {
        jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
        jclickCount = clickCount;
    }

    int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
                                                    modifierFlags);
    boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers);

    eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber,
            x, y, absoluteX, absoluteY, jmodifiers, jclickCount,
            jpopupTrigger, null);
}
 
Example 18
Source File: CPlatformResponder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handles mouse events.
 */
void handleMouseEvent(int eventType, int modifierFlags, int buttonNumber,
                      int clickCount, int x, int y, int absoluteX,
                      int absoluteY) {
    final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
    if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
            || buttonNumber > tk.getNumberOfButtons() - 1) {
        return;
    }

    int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
                                       NSEvent.nsToJavaEventType(eventType);

    int jbuttonNumber = MouseEvent.NOBUTTON;
    int jclickCount = 0;

    if (jeventType != MouseEvent.MOUSE_MOVED &&
        jeventType != MouseEvent.MOUSE_ENTERED &&
        jeventType != MouseEvent.MOUSE_EXITED)
    {
        jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
        jclickCount = clickCount;
    }

    int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
                                                    modifierFlags);
    boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers);

    eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber,
            x, y, absoluteX, absoluteY, jmodifiers, jclickCount,
            jpopupTrigger, null);
}
 
Example 19
Source File: XButtonPeer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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 20
Source File: XButtonPeer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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;
    }
}