java.awt.event.MouseEvent.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中java.awt.event.MouseEvent.<init>()方法的一些代码示例,展示了MouseEvent.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MouseEvent.<init>()方法的具体详情如下:
包路径:java.awt.event.MouseEvent
类名称:MouseEvent
方法名:<init>

MouseEvent.<init>介绍

[英]Constructs a MouseEvent object with the specified source component, type, modifiers, coordinates, and click count.

Note that passing in an invalid id results in unspecified behavior.
[中]使用指定的源组件、类型、修饰符、坐标和单击计数构造MouseEvent对象。
请注意,传入无效的id会导致未指定的行为。

代码示例

代码示例来源:origin: stackoverflow.com

jQuery.fn.d3Click = function () {
 this.each(function (i, e) {
  var evt = new MouseEvent("click");
  e.dispatchEvent(evt);
 });
};

代码示例来源:origin: stackoverflow.com

//...
try {
  var evt = new MouseEvent(...);
} catch (e) {
  window.open(fileURL, fileName);
}
//...

代码示例来源:origin: runelite/runelite

private MouseEvent translateEvent(MouseEvent e)
  {
    Dimension stretchedDimensions = client.getStretchedDimensions();
    Dimension realDimensions = client.getRealDimensions();

    int newX = (int) (e.getX() / (stretchedDimensions.width / realDimensions.getWidth()));
    int newY = (int) (e.getY() / (stretchedDimensions.height / realDimensions.getHeight()));

    return new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiersEx(),
        newX, newY, e.getClickCount(), e.isPopupTrigger(), e.getButton());
  }
}

代码示例来源:origin: checkstyle/checkstyle

if (getColumnClass(counter) == ParseTreeTableModel.class) {
  final MouseEvent mouseEvent = (MouseEvent) event;
  final MouseEvent newMouseEvent = new MouseEvent(tree, mouseEvent.getID(),
      mouseEvent.getWhen(), mouseEvent.getModifiersEx(),
      mouseEvent.getX() - getCellRect(0, counter, true).x,

代码示例来源:origin: nodebox/nodebox

public void mouseDragged(MouseEvent e) {
  isDragging = true;
  JComponent c = ColorWell.this;
  Point pt = e.getPoint();
  JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(c);
  pt = SwingUtilities.convertPoint(c, pt, frame.getContentPane());
  MouseEvent newEvent = new MouseEvent(colorPicker, e.getID(), e.getWhen(), e.getModifiers(), (int) pt.getX(), (int) pt.getY(), e.getClickCount(), e.isPopupTrigger(), e.getButton());
  colorPicker.dispatchEvent(newEvent);
}

代码示例来源:origin: nodebox/nodebox

public void mouseDragged(MouseEvent e) {
  isDragging = true;
  JComponent c = ColorWell.this;
  Point pt = e.getPoint();
  JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(c);
  pt = SwingUtilities.convertPoint(c, pt, frame.getContentPane());
  MouseEvent newEvent = new MouseEvent(colorPicker, e.getID(), e.getWhen(), e.getModifiers(), (int) pt.getX(), (int) pt.getY(), e.getClickCount(), e.isPopupTrigger(), e.getButton());
  colorPicker.dispatchEvent(newEvent);
}

代码示例来源:origin: apache/cloudstack

@Override
public void sendClientMouseEvent(InputEventType event, int x, int y, int code, int modifiers) {
  if (_client == null)
    return;
  updateFrontEndActivityTime();
  int mousecode = mapMouseButton(code);
  if (event == InputEventType.MOUSE_DOWN) {
    _mouseEventSource.mousePressed(new MouseEvent(_canvas, MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), mapMouseDownModifier(code, modifiers), x, y, 1, false,
        mousecode));
  }
  if (event == InputEventType.MOUSE_UP) {
    _mouseEventSource.mouseReleased((new MouseEvent(_canvas, MouseEvent.MOUSE_RELEASED, System.currentTimeMillis(), mapMouseUpModifier(code, modifiers), x, y, 1, false,
        mousecode)));
  }
  if (event == InputEventType.MOUSE_MOVE) {
    _mouseEventSource.mouseMoved(new MouseEvent(_canvas, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), mapModifier(modifiers), x, y, 0, false));
  }
}

代码示例来源:origin: stackoverflow.com

$("#test").click(function(){
 var evt = new MouseEvent("click");//make a mouse event
 //dispatch the event on the element.
 d3.select(".c3-arc-data1").node().dispatchEvent(evt);
});

代码示例来源:origin: stackoverflow.com

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

JButton jb = new JButton("Press!");
MouseEvent me = new MouseEvent(jb, // which
  MouseEvent.MOUSE_CLICKED, // what
  System.currentTimeMillis(), // when
  0, // no modifiers
  10, 10, // where: at (10, 10}
  1, // only 1 click 
  false); // not a popup trigger

jb.dispatchEvent(me);

代码示例来源:origin: net.imagej/ij

/** Makes a new mouse event from MouseEvent e with the Canvas c
 *    as source and the coordinates of Point p as X and Y.*/
private MouseEvent adaptEvent(MouseEvent e, Component c, Point p) {
  return new MouseEvent(c, e.getID(), e.getWhen(), e.getModifiers(),
    p.x, p.y, e.getClickCount(), e.isPopupTrigger());
}

代码示例来源:origin: org.microemu/microemu-javase-swing

private MouseEvent createAdaptedMouseEvent(MouseEvent e, int scale) {
  return new MouseEvent(e.getComponent(), e.getID(), e.getWhen(), e.getModifiers(), e.getX() / scale, e
      .getY()
      / scale, e.getClickCount(), e.isPopupTrigger(), e.getButton());
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

private MouseEvent clearClicks(MouseEvent e) {
  // Clears doubleclicks to prevent misses when switching sort order
  MouseEvent ee = new MouseEvent((Component)e.getSource(), e.getID(), e.getWhen(),
                  e.getModifiers(), e.getX(), e.getY(),
                  1, e.isPopupTrigger(), e.getButton());
  return ee;
}

代码示例来源:origin: google/sagetv

protected void fireDragGestureRecognized(int dragOp, java.awt.Point loc)
{
 java.awt.event.MouseEvent firstEvent = (java.awt.event.MouseEvent) events.remove(0);
 events.add(0, new java.awt.event.MouseEvent((java.awt.Component) firstEvent.getSource(),
   firstEvent.getID(),
   firstEvent.getWhen(),
   ((firstEvent.getModifiers() & java.awt.event.MouseEvent.BUTTON1_MASK) ==
   java.awt.event.MouseEvent.BUTTON1_MASK) ? java.awt.event.MouseEvent.BUTTON1_MASK :
    java.awt.event.MouseEvent.BUTTON3_MASK, firstEvent.getX(),
    firstEvent.getY(), firstEvent.getClickCount(), false));
 super.fireDragGestureRecognized(dragOp, loc);
}

代码示例来源:origin: freeplane/freeplane

public void actionPerformed(ActionEvent e) {
    final MouseEvent newMouseEvent = new MouseEvent(me.getComponent(),me.getID(), e.getWhen(), me.getModifiers(), me.getX(), me.getY(), clickCounter, me.isPopupTrigger(), button);
    delegate.mouseClicked(newMouseEvent);
    timer = null;
  }
});

代码示例来源:origin: freeplane/freeplane

private MouseEvent convertToComponentEvent(MouseEvent e, final Component component) {
  Point componentPoint = getPointAtComponent(e, component);
  final MouseEvent componentEvent = new MouseEvent(component,
    e.getID(),
    e.getWhen(),
    e.getModifiers(),
    componentPoint.x,
    componentPoint.y,
    e.getClickCount(),
    e.isPopupTrigger());
  return componentEvent;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

private void setupHeader(JTableHeader h) {
  h.setDraggedColumn(isSelected && isPressed ? getColumn() : null);
  
  MouseEvent e = isSelected && !isPressed ?
      new MouseEvent(h, MouseEvent.MOUSE_ENTERED, 1, 0, 1, 1, 0, false) :
      new MouseEvent(h, MouseEvent.MOUSE_EXITED, 1, 0, 0, 0, 0, false);
  h.dispatchEvent(e);
}

代码示例来源:origin: ca.mcgill/Sholl_Analysis

@Override
  public void actionPerformed(final ActionEvent e) {
    final MouseEvent me = new MouseEvent((Component) e.getSource(), MouseEvent.MOUSE_CLICKED,
        e.getWhen(), MouseEvent.MOUSE_PRESSED, 0, 0, 0, true);
    helpActionMouseListener.mousePressed(me);
  }
};

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

public static void fixSwingFocusBugWhenPopupCloses( Component c )
{
 // This is a fix to workaround a bug with Swing JPopupMenu.  Withou this
 // focus is stolen from a subsequent selected field. See Bug CC-1140.
 editor.util.EditorUtilities.rootPaneForComponent( c ).dispatchEvent( new MouseEvent( c, MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, 3, 3, 1, false ) );
}

代码示例来源:origin: sc.fiji/MTrackJ_

private void zoomout(final int cx, final int cy) {
  
  mtrackj.log("Zooming out...");
  mtrackj.canvas().zoomOut(cx,cy);
  getcoords(new MouseEvent(mtrackj.canvas(),0,0,0,cx,cy,0,false));
  mtrackj.logok();
}

代码示例来源:origin: sc.fiji/MTrackJ_

private void zoomin(final int cx, final int cy) {
  
  mtrackj.log("Zooming in...");
  mtrackj.canvas().zoomIn(cx,cy);
  getcoords(new MouseEvent(mtrackj.canvas(),0,0,0,cx,cy,0,false));
  mtrackj.logok();
}

相关文章