当前位置: 首页>>代码示例>>Java>>正文


Java MouseEvent.MOUSE_MOVED属性代码示例

本文整理汇总了Java中java.awt.event.MouseEvent.MOUSE_MOVED属性的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent.MOUSE_MOVED属性的具体用法?Java MouseEvent.MOUSE_MOVED怎么用?Java MouseEvent.MOUSE_MOVED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.event.MouseEvent的用法示例。


在下文中一共展示了MouseEvent.MOUSE_MOVED属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invokeTip

/** Hack to invoke tooltip on given JComponent, with given dismiss delay.
 * Triggers <br>
 * <code>comp.getToolTipText(MouseEvent)</code> and 
 * <code>comp.getToolTipLocation(MouseEvent)</code> with fake mousemoved 
 * MouseEvent, set to given coordinates.
 */
public static void invokeTip (JComponent comp, int x, int y, int dismissDelay) {
    final ToolTipManager ttm = ToolTipManager.sharedInstance();
    final int prevInit = ttm.getInitialDelay();
    prevDismiss = ttm.getDismissDelay();
    ttm.setInitialDelay(0);
    ttm.setDismissDelay(dismissDelay);
    
    MouseEvent fakeEvt = new MouseEvent(
            comp, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 
            0, x, y, 0, false);
    ttm.mouseMoved(fakeEvt);
    
    ttm.setInitialDelay(prevInit);
    Timer timer = new Timer(20, instance());
    timer.setRepeats(false);
    timer.start();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:TooltipHack.java

示例2: eventDispatched

public void eventDispatched(AWTEvent e) {
    if (popup == null) return;
    
    // Not a mouse event
    if (!(e instanceof MouseEvent)) return;
    MouseEvent me = (MouseEvent)e;
    
    // Event not relevant
    if (isIgnoreEvent(me)) return;
    
    // Mouse moved over popup
    if (me.getID() == MouseEvent.MOUSE_MOVED && overPopup(me)) return;
    
    if (!overPopup(me)) {
        // Mouse event outside of popup
        hidePopup();
    } else if (isForwardEvent(me)) {
        // Mouse event on popup, to be forwarded to table
        Point popupPoint = popupLocation;
        hidePopup();
        forwardEvent(me, popupPoint);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ProfilerTableHover.java

示例3: setLocation

@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);
  }
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:15,代码来源:Mouse.java

示例4: redirectMouseEvent

/**
 * Redirects the mouse event
 * @param evt
 * @param listener 
 */
private void redirectMouseEvent(MouseEvent evt, ListenerBean listener) {
    switch(evt.getID()) {
        case MouseEvent.MOUSE_DRAGGED:
            listener.listener.mouseDragged(evt);
        case MouseEvent.MOUSE_MOVED:
            listener.listener.mouseMoved(evt);
    }
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:13,代码来源:HierarchyMouseDispatcher.java

示例5: processMouseEvent

@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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:Outline.java

示例6: moveto

@Override public void moveto(Component component, int xOffset, int yOffset) {
    int buttons = deviceState.getButtons();
    if (component != deviceState.getComponent()) {
        if (deviceState.getComponent() != null) {
            dispatchEvent(new MouseEvent(deviceState.getComponent(), MouseEvent.MOUSE_EXITED, System.currentTimeMillis(),
                    deviceState.getModifierEx(), deviceState.x, deviceState.y, 0, false, buttons));
        }
        dispatchEvent(new MouseEvent(component, MouseEvent.MOUSE_ENTERED, System.currentTimeMillis(),
                deviceState.getModifierEx(), xOffset, yOffset, 0, false, buttons));
    }
    Component source = component;
    int id = MouseEvent.MOUSE_MOVED;
    Point p = new Point(xOffset, yOffset);
    if (buttons != 0) {
        id = MouseEvent.MOUSE_DRAGGED;
        source = deviceState.getDragSource();
        if (source != component) {
            p = SwingUtilities.convertPoint(component, xOffset, yOffset, source);
        }
    }
    int modifierEx = deviceState.getModifierEx() | deviceState.getButtonMask();
    MouseEvent mouseEvent = new MouseEvent(source, id, System.currentTimeMillis(), modifierEx, p.x, p.y, 0, false, buttons);
    dispatchEvent(mouseEvent);
    EventQueueWait.empty();
    deviceState.setComponent(component);
    deviceState.setMousePosition(xOffset, yOffset);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:27,代码来源:EventQueueDevice.java

示例7: handleMouseEvent

/**
 * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:CPlatformResponder.java

示例8: handleJavaMouseEvent

@Override
public void handleJavaMouseEvent( MouseEvent mouseEvent ) {
    super.handleJavaMouseEvent(mouseEvent);
    if (xtext != null)  {
        mouseEvent.setSource(xtext);
        int id = mouseEvent.getID();
        if (id == MouseEvent.MOUSE_DRAGGED || id == MouseEvent.MOUSE_MOVED)
            xtext.processMouseMotionEventImpl(mouseEvent);
        else
            xtext.processMouseEventImpl(mouseEvent);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:XTextFieldPeer.java

示例9: eventToString

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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:bug7146377.java

示例10: handleMouseEvent

/**
 * 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:CPlatformResponder.java

示例11: movedGeneratesSameEvents

public void movedGeneratesSameEvents() throws Throwable {
    events = MouseEvent.MOUSE_MOVED;
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            actionsArea.setText("");
        }
    });
    driver = new JavaDriver();
    WebElement b = driver.findElement(By.name("click-me"));
    WebElement t = driver.findElement(By.name("actions"));

    Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
    Dimension size = EventQueueWait.call_noexc(button, "getSize");
    Robot r = new Robot();
    r.setAutoDelay(10);
    r.setAutoWaitForIdle(true);
    Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
    Dimension size2 = EventQueueWait.call_noexc(actionsArea, "getSize");
    r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);

    r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    new EventQueueWait() {
        @Override public boolean till() {
            return actionsArea.getText().length() > 0;
        }
    }.wait("Waiting for actionsArea failed?");
    String expected = t.getText();
    tclear();
    r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);

    b.click();
    AssertJUnit.assertEquals(expected, t.getText());

    tclear();
    new Actions(driver).moveToElement(b).click().perform();
    AssertJUnit.assertEquals(expected, t.getText());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:43,代码来源:NativeEventsTest.java

示例12: isFocusChangeEvent

private boolean isFocusChangeEvent(int id) {
    return id != MouseEvent.MOUSE_ENTERED && id != MouseEvent.MOUSE_EXITED && id != MouseEvent.MOUSE_MOVED;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:3,代码来源:JavaRecorderHook.java

示例13: processMouseEvents

/**
 * Processes all caught <code>MouseEvent</code>s.
 *
 * @param e the <code>MouseEvent</code>
 */
private void processMouseEvents(MouseEvent e) {
    int tabNumber = getUI().tabForCoordinate(this, e.getX(), e.getY());
    if (tabNumber < 0)
        return;
    CloseTabIcon icon = (CloseTabIcon) getIconAt(tabNumber);
    if (icon != null) {
        Rectangle rect = icon.getBounds();
        Point pos = headerViewport == null ? new Point() : headerViewport
                .getViewPosition();
        Rectangle drawRect = new Rectangle(rect.x - pos.x, rect.y - pos.y,
                rect.width, rect.height);

        if (e.getID() == MouseEvent.MOUSE_PRESSED) {
            icon.mousepressed = e.getModifiers() == MouseEvent.BUTTON1_MASK;
            repaint(drawRect);
        } else if (e.getID() == MouseEvent.MOUSE_MOVED
                || e.getID() == MouseEvent.MOUSE_DRAGGED
                || e.getID() == MouseEvent.MOUSE_CLICKED) {
            pos.x += e.getX();
            pos.y += e.getY();
            if (rect.contains(pos)) {
                if (e.getID() == MouseEvent.MOUSE_CLICKED) {
                    int selIndex = getSelectedIndex();
                    if (fireCloseTab(selIndex)) {
                        if (selIndex > 0) {
                            // to prevent uncatchable null-pointers
                            Rectangle rec = getUI().getTabBounds(this,
                                    selIndex - 1);

                            MouseEvent event = new MouseEvent((Component) e
                                    .getSource(), e.getID() + 1, System
                                    .currentTimeMillis(), e.getModifiers(),
                                    rec.x, rec.y, e.getClickCount(), e
                                    .isPopupTrigger(), e
                                    .getButton());
                            dispatchEvent(event);
                        }
                        // the tab is being closed
                        // removeTabAt(tabNumber);
                        remove(selIndex);
                    } else {
                        icon.mouseover = false;
                        icon.mousepressed = false;
                        repaint(drawRect);
                    }
                } else {
                    icon.mouseover = true;
                    icon.mousepressed = e.getModifiers() == MouseEvent.BUTTON1_MASK;
                }
            } else {
                icon.mouseover = false;
            }
            repaint(drawRect);
        }
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:61,代码来源:CloseableTabbedPane.java

示例14: processMouseEvents

/**
 * Processes all caught <code>MouseEvent</code>s.
 *
 * @param e the <code>MouseEvent</code>
 */
private void processMouseEvents(MouseEvent e) {

    int tabNumber = getUI().tabForCoordinate(this, e.getX(), e.getY());

    if (tabNumber < 0) {
        return;
    }

    CloseTabIcon icon = (CloseTabIcon) getIconAt(tabNumber);

    if (icon != null) {
        // TODO: draw states of button '+'
        if (icon instanceof AddTabIcon && (e.getID() == MouseEvent.MOUSE_CLICKED)) {
            tabButtonPressed();
            return;
        }

        /* allow all tabs closing feature */
        if (getTabCount() <= (allowAllTabsClosing ? (addTabLabel != null ? 1 : 0)
                : addTabLabel != null ? 2 : 1)) {
            return;
        }

        Rectangle rect = icon.getBounds();
        Point pos = headerViewport == null ? new Point() : headerViewport
                .getViewPosition();
        Rectangle drawRect = new Rectangle(rect.x - pos.x, rect.y - pos.y,
                rect.width, rect.height);

        if (e.getID() == MouseEvent.MOUSE_PRESSED) {
            icon.mousepressed = e.getModifiers() == MouseEvent.BUTTON1_MASK;
            repaint(drawRect);
        } else if (e.getID() == MouseEvent.MOUSE_MOVED
                || e.getID() == MouseEvent.MOUSE_DRAGGED
                || e.getID() == MouseEvent.MOUSE_CLICKED) {
            pos.x += e.getX();
            pos.y += e.getY();
            if (rect.contains(pos)) {
                if (e.getID() == MouseEvent.MOUSE_CLICKED) {
                    int selIndex = getSelectedIndex();
                    if (fireCloseTab(selIndex)) {
                        if (selIndex > 0) {
                            // to prevent uncatchable null-pointers
                            Rectangle rec = getUI().getTabBounds(this,
                                    selIndex - 1);

                            MouseEvent event = new MouseEvent((Component) e
                                    .getSource(), e.getID() + 1, System
                                    .currentTimeMillis(), e.getModifiers(),
                                    rec.x, rec.y, e.getClickCount(), e
                                    .isPopupTrigger(), e
                                    .getButton());
                            dispatchEvent(event);
                        }
                        // the tab is being closed
                        // removeTabAt(tabNumber);
                        //remove(selIndex);
                        removeTabAt(selIndex);
                    } else {
                        icon.mouseover = false;
                        icon.mousepressed = false;
                        repaint(drawRect);
                    }
                } else {
                    icon.mouseover = true;
                    icon.mousepressed = e.getModifiers() == MouseEvent.BUTTON1_MASK;
                }
            } else {
                icon.mouseover = false;
            }
            repaint(drawRect);
        }
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:79,代码来源:CloseableTabbedPane.java


注:本文中的java.awt.event.MouseEvent.MOUSE_MOVED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。