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

The following are Jave code examples for showing how to use NOBUTTON 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: jdk8u-jdk   File: bug7170657.java   View Source Code Vote up 6 votes
public static void main(final String[] args) {
    final int mask = InputEvent.META_DOWN_MASK | InputEvent.CTRL_MASK;

    Frame f = new Frame();

    MouseEvent mwe = new MouseWheelEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                         1, 1, 1);
    MouseEvent mdme = new MenuDragMouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1,
                                             true, null, null);
    MouseEvent me = new MouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                   MouseEvent.NOBUTTON);

    test(f, mwe);
    test(f, mdme);
    test(f, me);

    if (FAILED) {
        throw new RuntimeException("Wrong mouse event");
    }
}
 
Example 2
Project: openjdk-jdk10   File: bug7170657.java   View Source Code Vote up 6 votes
public static void main(final String[] args) {
    final int mask = InputEvent.META_DOWN_MASK | InputEvent.CTRL_MASK;

    Frame f = new Frame();

    MouseEvent mwe = new MouseWheelEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                         1, 1, 1);
    MouseEvent mdme = new MenuDragMouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1,
                                             true, null, null);
    MouseEvent me = new MouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
                                   MouseEvent.NOBUTTON);

    test(f, mwe);
    test(f, mdme);
    test(f, me);

    if (FAILED) {
        throw new RuntimeException("Wrong mouse event");
    }
}
 
Example 3
Project: litiengine   File: Mouse.java   View Source Code Vote up 5 votes
@Override
public void setLocation(final Point2D adjustMouse) {
  if (adjustMouse == null) {
    return;
  }

  this.location = adjustMouse;
  this.lastLocation = adjustMouse;

  final MouseEvent mouseEvent = new MouseEvent(Game.getScreenManager().getRenderComponent(), MouseEvent.MOUSE_MOVED, 0, 0, (int) this.getLocation().getX(), (int) this.getLocation().getY(), 0, false, MouseEvent.NOBUTTON);
  final MouseEvent wrappedEvent = this.createEvent(mouseEvent);
  for (final Consumer<MouseEvent> cons : this.mouseMovedConsumer) {
    cons.accept(wrappedEvent);
  }
}
 
Example 4
Project: OpenJSharp   File: SunDropTargetEvent.java   View Source Code Vote up 5 votes
public SunDropTargetEvent(Component source, int id, int x, int y,
                          SunDropTargetContextPeer.EventDispatcher d) {
    super(source, id, System.currentTimeMillis(), 0, x, y, 0, 0, 0,
          false,  MouseEvent.NOBUTTON);
    dispatcher = d;
    dispatcher.registerEvent(this);
}
 
Example 5
Project: OpenJSharp   File: CPlatformResponder.java   View Source Code Vote up 5 votes
/**
 * 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 6
Project: jdk8u-jdk   File: SunDropTargetEvent.java   View Source Code Vote up 5 votes
public SunDropTargetEvent(Component source, int id, int x, int y,
                          SunDropTargetContextPeer.EventDispatcher d) {
    super(source, id, System.currentTimeMillis(), 0, x, y, 0, 0, 0,
          false,  MouseEvent.NOBUTTON);
    dispatcher = d;
    dispatcher.registerEvent(this);
}
 
Example 7
Project: jdk8u-jdk   File: CPlatformResponder.java   View Source Code Vote up 5 votes
/**
 * 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 8
Project: openjdk-jdk10   File: SunDropTargetEvent.java   View Source Code Vote up 5 votes
public SunDropTargetEvent(Component source, int id, int x, int y,
                          SunDropTargetContextPeer.EventDispatcher d) {
    super(source, id, System.currentTimeMillis(), 0, x, y, 0, 0, 0,
          false,  MouseEvent.NOBUTTON);
    dispatcher = d;
    dispatcher.registerEvent(this);
}
 
Example 9
Project: openjdk-jdk10   File: CPlatformResponder.java   View Source Code Vote up 5 votes
/**
 * 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 10
Project: incubator-netbeans   File: AbstractListUI.java   View Source Code Vote up 4 votes
private boolean redispatchComponent(MouseEvent e) {
    Point p = e.getPoint();
    int index = list.locationToIndex(p);
    if (index < 0 || index >= list.getModel().getSize()) {
        return false;
    }

    ListCellRenderer renderer = list.getCellRenderer();
    if (null == renderer) {
        return false;
    }
    Component renComponent = renderer.getListCellRendererComponent(list, list.getModel().getElementAt(index), index, false, false);
    if (null == renComponent) {
        return false;
    }
    Rectangle rect = list.getCellBounds(index, index);
    if (null == rect) {
        return false;
    }
    renComponent.setBounds(0, 0, rect.width, rect.height);
    renComponent.doLayout();
    Point p3 = rect.getLocation();

    Point p2 = new Point(p.x - p3.x, p.y - p3.y);
    Component dispatchComponent =
            SwingUtilities.getDeepestComponentAt(renComponent,
            p2.x, p2.y);
    if ( e.isPopupTrigger() &&
         dispatchComponent instanceof LinkButton && 
         !((LinkButton)dispatchComponent).isHandlingPopupEvents() ) 
    {
        return false;
    } 
    if (dispatchComponent instanceof AbstractButton) {
        if (!((AbstractButton) dispatchComponent).isEnabled()) {
            return false;
        }
        Point p4 = SwingUtilities.convertPoint(renComponent, p2, dispatchComponent);
        MouseEvent newEvent = new MouseEvent(dispatchComponent,
                e.getID(),
                e.getWhen(),
                e.getModifiers(),
                p4.x, p4.y,
                e.getClickCount(),
                e.isPopupTrigger(),
                MouseEvent.NOBUTTON);
        dispatchComponent.dispatchEvent(newEvent);
        list.repaint(rect);
        e.consume();
        return true;
    }
    return false;
}
 
Example 11
Project: incubator-netbeans   File: Outline.java   View Source Code Vote up 4 votes
@Override
public String getToolTipText(MouseEvent event) {
    try {
        // Required to really get the tooltip text:
        putClientProperty("ComputingTooltip", Boolean.TRUE);

        toolTip = null;
        String tipText = null;
        Point p = event.getPoint();

        // Locate the renderer under the event location
        int hitColumnIndex = columnAtPoint(p);
        int hitRowIndex = rowAtPoint(p);

        if ((hitColumnIndex != -1) && (hitRowIndex != -1)) {
            //Outline tbl = (Outline) table;
            if (convertColumnIndexToModel(hitColumnIndex) == 0) {   // tree column index
                // For tree column get the tooltip directly from the renderer data provider
                RenderDataProvider rendata = getRenderDataProvider();
                if (rendata != null) {
                    Object value = getValueAt(hitRowIndex, hitColumnIndex);
                    if (value != null) {
                        String toolT = rendata.getTooltipText(value);
                        if (toolT != null && (toolT = toolT.trim ()).length () > 0) {
                            tipText = toolT;
                        }
                    }
                }
            }

            TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex);
            Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex);

            // Now have to see if the component is a JComponent before
            // getting the tip
            if (component instanceof JComponent) {
                // Convert the event to the renderer's coordinate system
                Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false);
                p.translate(-cellRect.x, -cellRect.y);
                MouseEvent newEvent = new MouseEvent(component, event.getID(),
                                          event.getWhen(), event.getModifiers(),
                                          p.x, p.y,
                                          event.getXOnScreen(),
                                          event.getYOnScreen(),
                                          event.getClickCount(),
                                          event.isPopupTrigger(),
                                          MouseEvent.NOBUTTON);

                if (tipText == null) {
                    tipText = ((JComponent)component).getToolTipText(newEvent);
                }
                toolTip = ((JComponent)component).createToolTip();
            }
        }

        // No tip from the renderer get our own tip
        if (tipText == null)
            tipText = getToolTipText();

        if (tipText != null) {
            tipText = tipText.trim();
            if (tipText.length() > MAX_TOOLTIP_LENGTH &&
                !tipText.regionMatches(false, 0, "<html>", 0, 6)) {   // Do not cut HTML tooltips

                tipText = tipText.substring(0, MAX_TOOLTIP_LENGTH) + "...";
            }
        }
        return tipText;
    } finally {
        putClientProperty("ComputingTooltip", Boolean.FALSE);
    }
    //return super.getToolTipText(event);
}
 
Example 12
Project: The-Mysterious-Mind-Of-Jack   File: Mouse.java   View Source Code Vote up 4 votes
public void mouseReleased(MouseEvent e) {
	mouseB = MouseEvent.NOBUTTON;

	MouseReleasedEvent event = new MouseReleasedEvent(e.getButton(), e.getX(), e.getY());
	eventListener.onEvent(event);
}
 
Example 13
Project: OpenJSharp   File: MenuDragMouseEvent.java   View Source Code Vote up 3 votes
/**
 * Constructs a MenuDragMouseEvent object.
 * <p>Even if inconsistent values for relative and absolute coordinates are
 * passed to the constructor, the MenuDragMouseEvent instance is still
 * created.
 * @param source        the Component that originated the event
 *                      (typically <code>this</code>)
 * @param id            an int specifying the type of event, as defined
 *                      in {@link java.awt.event.MouseEvent}
 * @param when          a long identifying the time the event occurred
 * @param modifiers     an int specifying any modifier keys held down,
 *                      as specified in {@link java.awt.event.InputEvent}
 * @param x             an int specifying the horizontal position at which
 *                      the event occurred, in pixels
 * @param y             an int specifying the vertical position at which
 *                      the event occurred, in pixels
 * @param xAbs          an int specifying the horizontal absolute position at which
 *                      the event occurred, in pixels
 * @param yAbs          an int specifying the vertical absolute position at which
 *                      the event occurred, in pixels
 * @param clickCount    an int specifying the number of mouse-clicks
 * @param popupTrigger  a boolean -- true if the event {should?/did?}
 *                      trigger a popup
 * @param p             an array of MenuElement objects specifying a path
 *                        to a menu item affected by the drag
 * @param m             a MenuSelectionManager object that handles selections
 * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
 * @since 1.6
 */
public MenuDragMouseEvent(Component source, int id, long when,
                          int modifiers, int x, int y, int xAbs,
                          int yAbs, int clickCount,
                          boolean popupTrigger, MenuElement p[],
                          MenuSelectionManager m) {
    super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount,
          popupTrigger, MouseEvent.NOBUTTON);
    path = p;
    manager = m;
}
 
Example 14
Project: jdk8u-jdk   File: MenuDragMouseEvent.java   View Source Code Vote up 3 votes
/**
 * Constructs a MenuDragMouseEvent object.
 * <p>Even if inconsistent values for relative and absolute coordinates are
 * passed to the constructor, the MenuDragMouseEvent instance is still
 * created.
 * @param source        the Component that originated the event
 *                      (typically <code>this</code>)
 * @param id            an int specifying the type of event, as defined
 *                      in {@link java.awt.event.MouseEvent}
 * @param when          a long identifying the time the event occurred
 * @param modifiers     an int specifying any modifier keys held down,
 *                      as specified in {@link java.awt.event.InputEvent}
 * @param x             an int specifying the horizontal position at which
 *                      the event occurred, in pixels
 * @param y             an int specifying the vertical position at which
 *                      the event occurred, in pixels
 * @param xAbs          an int specifying the horizontal absolute position at which
 *                      the event occurred, in pixels
 * @param yAbs          an int specifying the vertical absolute position at which
 *                      the event occurred, in pixels
 * @param clickCount    an int specifying the number of mouse-clicks
 * @param popupTrigger  a boolean -- true if the event {should?/did?}
 *                      trigger a popup
 * @param p             an array of MenuElement objects specifying a path
 *                        to a menu item affected by the drag
 * @param m             a MenuSelectionManager object that handles selections
 * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
 * @since 1.6
 */
public MenuDragMouseEvent(Component source, int id, long when,
                          int modifiers, int x, int y, int xAbs,
                          int yAbs, int clickCount,
                          boolean popupTrigger, MenuElement p[],
                          MenuSelectionManager m) {
    super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount,
          popupTrigger, MouseEvent.NOBUTTON);
    path = p;
    manager = m;
}
 
Example 15
Project: openjdk-jdk10   File: MenuDragMouseEvent.java   View Source Code Vote up 3 votes
/**
 * Constructs a MenuDragMouseEvent object.
 * <p>Even if inconsistent values for relative and absolute coordinates are
 * passed to the constructor, the MenuDragMouseEvent instance is still
 * created.
 * @param source        the Component that originated the event
 *                      (typically <code>this</code>)
 * @param id            an int specifying the type of event, as defined
 *                      in {@link java.awt.event.MouseEvent}
 * @param when          a long identifying the time the event occurred
 * @param modifiers     an int specifying any modifier keys held down,
 *                      as specified in {@link java.awt.event.InputEvent}
 * @param x             an int specifying the horizontal position at which
 *                      the event occurred, in pixels
 * @param y             an int specifying the vertical position at which
 *                      the event occurred, in pixels
 * @param xAbs          an int specifying the horizontal absolute position at which
 *                      the event occurred, in pixels
 * @param yAbs          an int specifying the vertical absolute position at which
 *                      the event occurred, in pixels
 * @param clickCount    an int specifying the number of mouse-clicks
 * @param popupTrigger  a boolean -- true if the event {should?/did?}
 *                      trigger a popup
 * @param p             an array of MenuElement objects specifying a path
 *                        to a menu item affected by the drag
 * @param m             a MenuSelectionManager object that handles selections
 * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
 * @since 1.6
 */
public MenuDragMouseEvent(Component source, int id, long when,
                          int modifiers, int x, int y, int xAbs,
                          int yAbs, int clickCount,
                          boolean popupTrigger, MenuElement p[],
                          MenuSelectionManager m) {
    super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount,
          popupTrigger, MouseEvent.NOBUTTON);
    path = p;
    manager = m;
}