Java Code Examples for java.awt.event.MouseEvent#setSource()

The following examples show how to use java.awt.event.MouseEvent#setSource() . 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: bug6583251.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                createGui();
            }
        });

        Robot robot = new Robot();
        robot.waitForIdle();
        menu.show(frame, 0, 0);
        robot.waitForIdle();

        TrayIcon trayIcon = new TrayIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB));
        MouseEvent ev = new MouseEvent(
                new JButton(), MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, 0, 0, 1, false);
        ev.setSource(trayIcon);
        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ev);
    }
 
Example 2
Source File: bug6690791.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}
 
Example 3
Source File: XTextFieldPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example 4
Source File: bug6690791.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}
 
Example 5
Source File: XTextFieldPeer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example 6
Source File: UIUtilities.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Translates a {@link MouseEvent} from one component to another.
 *
 * @param event The event that will be forwarded.
 * @param from  The component that originally received the event.
 * @param to    The component the event should be forwarded to.
 */
public static void translateMouseEvent(MouseEvent event, Component from, Component to) {
    Point evtPt = event.getPoint();
    Point pt    = new Point(evtPt);
    convertPoint(pt, from, to);
    event.setSource(to);
    event.translatePoint(pt.x - evtPt.x, pt.y - evtPt.y);
}
 
Example 7
Source File: bug6690791.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}
 
Example 8
Source File: XTextFieldPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example 9
Source File: bug6690791.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}
 
Example 10
Source File: bug6690791.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}
 
Example 11
Source File: bug6690791.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}
 
Example 12
Source File: XTextFieldPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example 13
Source File: bug6690791.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}
 
Example 14
Source File: XTextFieldPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example 15
Source File: bug6690791.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}
 
Example 16
Source File: XTextFieldPeer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example 17
Source File: bug6690791.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}
 
Example 18
Source File: XTextFieldPeer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example 19
Source File: XTextFieldPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example 20
Source File: bug6690791.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    MouseEvent me = new MouseEvent(new JLabel(), MouseEvent.MOUSE_CLICKED,
            System.currentTimeMillis(), MouseEvent.ALT_MASK,
            10, 10, 100, 100, 1, false, MouseEvent.BUTTON1);
    me.setSource(new Object());
    MenuSelectionManager.defaultManager().processMouseEvent(me);
}