类java.awt.event.MouseMotionListener源码实例Demo

下面列出了怎么用java.awt.event.MouseMotionListener的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ghidra   文件: GraphViewerTest.java
private void hoverEdge(TestEdge edge) {

		// if the vertex is visible, then at least part of the edge will be
		ensureVertexVisible(edge.getStart());

		Point2D graphSpaceEdgePoint = findHoverPointInGraphSpace(edge);
		Point viewPoint =
			GraphViewerUtils.translatePointFromGraphSpaceToViewSpace(graphSpaceEdgePoint, viewer);

		int mods = 0;
		MouseEvent e = new MouseEvent(viewer, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(),
			mods, viewPoint.x, viewPoint.y, 0, false);

		MouseMotionListener[] listeners = viewer.getMouseMotionListeners();
		swing(() -> {
			for (MouseMotionListener listener : listeners) {
				listener.mouseMoved(e);
			}
		});

		tooltipSpy.clearTooltipTriggered();
		AbstractGTest.waitForCondition(() -> tooltipSpy.isTooltipTriggered(),
			"Timed-out waiting for tooltip to appear");
		waitForSwing();
	}
 
源代码2 项目: freecol   文件: Canvas.java
/**
 * Removes components that is only used when in game.
 */
public void removeInGameComponents() {
    // remove listeners, they will be added when launching the new game...
    KeyListener[] keyListeners = getKeyListeners();
    for (KeyListener keyListener : keyListeners) {
        removeKeyListener(keyListener);
    }

    MouseListener[] mouseListeners = getMouseListeners();
    for (MouseListener mouseListener : mouseListeners) {
        removeMouseListener(mouseListener);
    }

    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    for (MouseMotionListener mouseMotionListener : mouseMotionListeners) {
        removeMouseMotionListener(mouseMotionListener);
    }

    for (Component c : getComponents()) {
        removeFromCanvas(c);
    }
}
 
源代码3 项目: freecol   文件: InGameMenuBar.java
/**
 * Creates a new {@code FreeColMenuBar}. This menu bar will include
 * all of the submenus and items.
 *
 * @param freeColClient The main controller.
 * @param listener An optional mouse motion listener.
 */
public InGameMenuBar(FreeColClient freeColClient, MouseMotionListener listener) {
    // FIXME: FreeColClient should not have to be passed in to
    // this class.  This is only a menu bar, it doesn't need a
    // reference to the main controller.  The only reason it has
    // one now is because DebugMenu needs it.  And DebugMenu needs
    // it because it is using inner classes for ActionListeners
    // and those inner classes use the reference.  If those inner
    // classes were in seperate classes, when they were created,
    // they could use the FreeColClient reference of the
    // ActionManger.  So DebugMenu needs to be refactored to remove
    // inner classes so that this MenuBar can lose its unnecessary
    // reference to the main controller.  See FreeColMenuTest.
    //
    // Okay, I lied.. the update() and paintComponent() methods in
    // this MenuBar use freeColClient, too. But so what.  Move
    // those to another class too. :)
    super(freeColClient);

    // Add a mouse listener so that autoscrolling can happen in
    // this menubar
    this.addMouseMotionListener(listener);
    
    reset();
}
 
源代码4 项目: FCMFrame   文件: CCSystem.java
/**
 * Set whether the coordinate system is movable with the mouse, i.e.
 * the scope of the system changes as the the mouse is clicked, held
 * and dragged over the system.
 * 
 * @param movable
 *        If true, move is possible.
 */
public void setMovable(boolean movable) {
    if (this.movable && movable) return;
    if (!this.movable && !movable) return;
    
    if (movable) {
        addMouseListener(mouseListener);
        addMouseMotionListener((MouseMotionListener) mouseListener);
    }
    else {
        removeMouseListener(mouseListener);
        removeMouseMotionListener((MouseMotionListener) mouseListener);
    }
    
    movable = !movable;
}
 
源代码5 项目: java-swing-tips   文件: MainPanel.java
private MainPanel() {
  super(new BorderLayout());

  // title, resizable, closable, maximizable, iconifiable
  JInternalFrame immovableFrame = new JInternalFrame("immovable", false, false, true, true);
  Component north = ((BasicInternalFrameUI) immovableFrame.getUI()).getNorthPane();
  MouseMotionListener[] actions = north.getListeners(MouseMotionListener.class);
  for (MouseMotionListener l: actions) {
    north.removeMouseMotionListener(l);
  }
  // immovableFrame.setLocation(0, 0);
  immovableFrame.setSize(160, 0);
  desktop.add(immovableFrame);
  immovableFrame.setVisible(true);

  desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
  desktop.addComponentListener(new ComponentAdapter() {
    @Override public void componentResized(ComponentEvent e) {
      immovableFrame.setSize(immovableFrame.getSize().width, e.getComponent().getSize().height);
    }
  });

  add(desktop);
  add(createMenuBar(), BorderLayout.NORTH);
  setPreferredSize(new Dimension(320, 240));
}
 
源代码6 项目: CrossMobile   文件: SwingWrapperClickConsumer.java
@Override
public void mouseDragged(MouseEvent e) {
    SwingGraphicsBridge.component.mouseDragged(e);
    if (active)
        for (MouseMotionListener mouseMotion1 : mouseMotion)
            mouseMotion1.mouseDragged(e);
}
 
源代码7 项目: CrossMobile   文件: SwingWrapperClickConsumer.java
@Override
public void mouseMoved(MouseEvent e) {
    SwingGraphicsBridge.component.mouseMoved(e);
    if (active)
        for (MouseMotionListener mouseMotion1 : mouseMotion)
            mouseMotion1.mouseMoved(e);
}
 
源代码8 项目: amodeus   文件: JMapController.java
public JMapController(JMapViewer map) {
    this.map = map;
    if (this instanceof MouseListener)
        map.addMouseListener((MouseListener) this);
    if (this instanceof MouseWheelListener)
        map.addMouseWheelListener((MouseWheelListener) this);
    if (this instanceof MouseMotionListener)
        map.addMouseMotionListener((MouseMotionListener) this);
}
 
源代码9 项目: ramus   文件: Handler.java
/**
 * Strips off the UI's mouse listeners attached to the associated toolbar
 * and replaces them with this handler's listeners.
 */
private void installListeners() {
    if (!ourVersionIsCompatible)
        return;

    ourToolBar.removePropertyChangeListener("UI", ourUIListener);

    // Uninstall the current ui, collect the remaining listeners
    // on the toolbar, and reinstall the ui...
    final ComponentUI ui = ourToolBar.getUI();
    ui.uninstallUI(ourToolBar);
    final java.util.List mList = Arrays.asList(ourToolBar
            .getListeners(MouseListener.class));

    final java.util.List mmList = Arrays.asList(ourToolBar
            .getListeners(MouseMotionListener.class));
    ui.installUI(ourToolBar);

    // ...then remove the listeners that were added by the ui...
    final MouseListener[] ml = ourToolBar
            .getListeners(MouseListener.class);
    final MouseMotionListener[] mml = ourToolBar
            .getListeners(MouseMotionListener.class);

    for (int i = 0; i < ml.length; i++) {
        if (!mList.contains(ml[i]))
            ourToolBar.removeMouseListener(ml[i]);
    }

    for (int i = 0; i < mml.length; i++) {
        if (!mmList.contains(mml[i]))
            ourToolBar.removeMouseMotionListener(mml[i]);
    }

    // ...and add our listeners to the toolbar.
    ourToolBar.addMouseListener(ourDragListener);
    ourToolBar.addMouseMotionListener(ourDragListener);
    ourToolBar.addPropertyChangeListener("UI", ourUIListener);
}
 
源代码10 项目: freecol   文件: MapEditorMenuBar.java
/**
 * Creates a new {@code MapEditorMenuBar}. This menu bar will include
 * all of the submenus and items.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param listener An optional mouse motion listener.
 */
public MapEditorMenuBar(final FreeColClient freeColClient, MouseMotionListener listener) {
    super(freeColClient);

    // Add a mouse listener so that autoscrolling can happen in this menubar
    this.addMouseMotionListener(listener);
    reset();
}
 
源代码11 项目: openjdk-jdk9   文件: ComponentOperator.java
/**
 * Maps {@code Component.addMouseMotionListener(MouseMotionListener)}
 * through queue
 */
public void addMouseMotionListener(final MouseMotionListener mouseMotionListener) {
    runMapping(new MapVoidAction("addMouseMotionListener") {
        @Override
        public void map() {
            getSource().addMouseMotionListener(mouseMotionListener);
        }
    });
}
 
源代码12 项目: openjdk-jdk9   文件: ComponentOperator.java
/**
 * Maps
 * {@code Component.removeMouseMotionListener(MouseMotionListener)}
 * through queue
 */
public void removeMouseMotionListener(final MouseMotionListener mouseMotionListener) {
    runMapping(new MapVoidAction("removeMouseMotionListener") {
        @Override
        public void map() {
            getSource().removeMouseMotionListener(mouseMotionListener);
        }
    });
}
 
public void removeListener() {
    for (MouseListener ml : com.getMouseListeners()) {
        com.removeMouseListener(ml);
    }
    for (MouseMotionListener mml : com.getMouseMotionListeners()) {
        com.removeMouseMotionListener(mml);
    }
    for (KeyListener kl : com.getKeyListeners()) {
        com.removeKeyListener(kl);
    }
    reset();
    com.repaint();
}
 
源代码14 项目: pumpernickel   文件: DecoratedTreeUI.java
@Override
public void mouseDragged(MouseEvent e) {
	mouseX = e.getX();
	mouseY = e.getY();
	repaintDecorations(false);
	if (mouseListener instanceof MouseMotionListener)
		((MouseMotionListener) mouseListener).mouseDragged(e);
}
 
源代码15 项目: pumpernickel   文件: DecoratedTreeUI.java
@Override
public void mouseMoved(MouseEvent e) {
	mouseX = e.getX();
	mouseY = e.getY();
	repaintDecorations(false);
	if (mouseListener instanceof MouseMotionListener)
		((MouseMotionListener) mouseListener).mouseMoved(e);
}
 
源代码16 项目: sldeditor   文件: CharMap4Grid.java
/**
 * Instantiates a new char map4 grid.
 *
 * @param charMap4
 */
public CharMap4Grid(CharMap4 charMap4) {
    super(); // initialize our superclass first (JPanel)

    this.charMap4 = charMap4;
    // Set class instance variables to undefined values that we will recognise
    // if we are called before the layout and first "paint" is complete. */

    cellCount = charCount = glyphCount = 0; // no chars or glyphs to display
    clickIndex = NO_MOUSE; // cell index of clicked character
    clickStartX = clickStartY = NO_MOUSE; // no starting coordinates for click
    cornerIndex = 0; // cell index of top-left corner
    fontData = null; // information about current display font
    horizStep = 100; // horizontal offset from one cell to next
    hoverIndex = NO_MOUSE; // cell index of mouse over character
    lineAscent = 100; // number of pixels above baseline
    lineHeight = 100; // height of each display line in pixels
    maxWidth = 100; // maximum pixel width of all characters
    panelColumns = 10; // number of complete text columns displayed
    panelCount = -1; // saved value of <cellCount> used previously
    panelFont = null; // saved font for drawing text on this panel
    panelHeight = panelWidth = -1; // saved panel height and width in pixels
    panelRows = 10; // number of complete lines (rows) displayed
    vertiStep = 100; // vertical offset from one cell to next

    /* Install our mouse and scroll listeners. */

    this.addMouseListener((MouseListener) this);
    this.addMouseMotionListener((MouseMotionListener) this);
    this.addMouseWheelListener((MouseWheelListener) this);
    // this.setFocusable(false); // we don't handle keyboard input, owner does

}
 
源代码17 项目: Course_Generator   文件: JMapController.java
public JMapController(JMapViewer map) {
	this.map = map;
	if (this instanceof MouseListener)
		map.addMouseListener((MouseListener) this);
	if (this instanceof MouseWheelListener)
		map.addMouseWheelListener((MouseWheelListener) this);
	if (this instanceof MouseMotionListener)
		map.addMouseMotionListener((MouseMotionListener) this);
}
 
源代码18 项目: jexer   文件: SwingComponent.java
/**
 * Adds the specified mouse motion listener to receive mouse motion
 * events from this component. If listener l is null, no exception is
 * thrown and no action is performed.
 *
 * @param l the mouse motion listener
 */
public void addMouseMotionListener(MouseMotionListener l) {
    if (frame != null) {
        frame.addMouseMotionListener(l);
    } else {
        component.addMouseMotionListener(l);
    }
}
 
源代码19 项目: seaglass   文件: SeaGlassTabbedPaneUI.java
/**
 * Creates a new SeaGlassTabbedPaneMouseHandler object.
 *
 * @param originalMouseListener the original mouse handler.
 */
public SeaGlassTabbedPaneMouseHandler(MouseListener originalMouseListener) {
    delegate  = originalMouseListener;
    delegate2 = (MouseMotionListener) originalMouseListener;

    closeButtonHoverIndex = -1;
    closeButtonArmedIndex = -1;
}
 
源代码20 项目: ganttproject   文件: ResourceLoadGraphicArea.java
@Override
protected MouseMotionListener getMouseMotionListener() {
  if (myMouseMotionListener == null) {
    myMouseMotionListener = new MouseMotionListenerBase(getUIFacade(), getImplementation());
  }
  return myMouseMotionListener;
}
 
源代码21 项目: java-swing-tips   文件: MainPanel.java
@Override public void updateUI() {
  super.updateUI();
  BasicInternalFrameUI ui = (BasicInternalFrameUI) getUI();
  Component titleBar = ui.getNorthPane();
  for (MouseMotionListener l: titleBar.getListeners(MouseMotionListener.class)) {
    titleBar.removeMouseMotionListener(l);
  }
  DragWindowListener dwl = new DragWindowListener();
  titleBar.addMouseListener(dwl);
  titleBar.addMouseMotionListener(dwl);
}
 
源代码22 项目: java-swing-tips   文件: MainPanel.java
private MainPanel() {
  super(new BorderLayout());
  JTabbedPane tabbedPane = new JTabbedPane() {
    private transient MouseMotionListener hoverHandler;
    @Override public void updateUI() {
      removeMouseMotionListener(hoverHandler);
      super.updateUI();
      hoverHandler = new MouseAdapter() {
        @Override public void mouseMoved(MouseEvent e) {
          JTabbedPane source = (JTabbedPane) e.getComponent();
          int num = source.indexAtLocation(e.getX(), e.getY());
          for (int i = 0; i < source.getTabCount(); i++) {
            source.setForegroundAt(i, i == num ? Color.GREEN : Color.BLACK);
          }
        }
      };
      addMouseMotionListener(hoverHandler);
    }
  };
  tabbedPane.addTab("11111", new JScrollPane(new JTree()));
  tabbedPane.addTab("22222", new JScrollPane(new JLabel("asdfasdfsadf")));
  tabbedPane.addTab("33333", new JScrollPane(new JTree()));
  tabbedPane.addTab("44444", new JScrollPane(new JLabel("qerwqerqwerqwe")));
  tabbedPane.addTab("55555", new JScrollPane(new JTree()));

  add(tabbedPane);
  setPreferredSize(new Dimension(320, 240));
}
 
源代码23 项目: microba   文件: BasicMarkerBarUI.java
protected MarkerBarListener lookupListsner(MarkerBar markerBar) {
	MouseMotionListener[] listeners = markerBar.getMouseMotionListeners();

	if (listeners != null) {
		for (int counter = 0; counter < listeners.length; counter++) {
			if (listeners[counter] instanceof MarkerBarListener) {
				return (MarkerBarListener) listeners[counter];
			}
		}
	}
	return null;
}
 
源代码24 项目: JavaGame   文件: Menu.java
private void render() {
	// frame.getFrame().getContentPane().setBackground(Color.GREEN);
	frame.addMouseMotionListener((MouseMotionListener) Mouse);
	frame.addMouseListener(Mouse);
	frame.addKeyListener(Key);
	BufferStrategy bs = frame.getBufferStrategy();
	if (bs == null) {
		frame.createBufferStrategy(3);
		return;
	}
	Graphics g = bs.getDrawGraphics();
	g.setColor(Color.BLACK);
	g.fillRect(0, 0, frame.getWidth(), frame.getHeight());
	g.setColor(new Color(0xFF660000));
	g.fillRect(0, 0, WIDTH * 3, HEIGHT * 3);
	g.setColor(new Color(0xFFFF9900));
	g.setFont(font.getArial());
	if (isGameOver()) {
		g.drawString("GAME OVER... What will you do now?", 35, 30);
	} else {
		String name = (Game.getJdata_UserName().length() >= 1) ? WordUtils
				.capitalizeFully(Game.getJdata_UserName()).toString()
				: "Player";
		g.drawString("Welcome to JavaGame " + name, 35, 30);
	}
	g.drawLine(0, HEIGHT * 3, 0, 0);
	g.drawLine(0, 0, (WIDTH * 3), 0);
	g.drawLine((WIDTH * 3), 0, (WIDTH * 3), (HEIGHT * 3));
	g.drawLine(0, (HEIGHT * 3), (WIDTH * 3), (HEIGHT * 3));
	// (LEFT,DOWN,WIDTH,HEIGHT)
	paintButtons(isSelectedStart(), isSelectedExit(), g);
	bs.show();
	g.dispose();

}
 
源代码25 项目: consulo   文件: IdeGlassPaneImpl.java
private static void fireMouseMotion(MouseMotionListener listener, final MouseEvent event) {
  switch (event.getID()) {
    case MouseEvent.MOUSE_DRAGGED:
      listener.mouseDragged(event);
    case MouseEvent.MOUSE_MOVED:
      listener.mouseMoved(event);
  }
}
 
源代码26 项目: consulo   文件: ListenerUtil.java
public static void addMouseMotionListener(Component c, MouseMotionListener l) {
  c.addMouseMotionListener(l);
  if (c instanceof Container) {
    final Container container = (Container)c;
    Component[] children = container.getComponents();
    for (Component child : children) {
      addMouseMotionListener(child, l);
    }
  }
}
 
源代码27 项目: consulo   文件: ListenerUtil.java
public static void removeMouseMotionListener(final Component component, final MouseMotionListener motionListener) {
  component.removeMouseMotionListener(motionListener);
  if (component instanceof Container) {
    Container container = (Container)component;
    for (int i = 0; i < container.getComponentCount(); i++) {
      removeMouseMotionListener(container.getComponent(i), motionListener);
    }
  }
}
 
源代码28 项目: darklaf   文件: DarkNumberingPaneUI.java
protected MouseMotionListener getMouseMotionListener() {
    return getHandler();
}
 
源代码29 项目: darklaf   文件: DummyEditorPane.java
@Override
public synchronized void addMouseMotionListener(final MouseMotionListener l) {}
 
源代码30 项目: darklaf   文件: DummyTextArea.java
@Override
public synchronized void addMouseMotionListener(final MouseMotionListener l) {}