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

The following are Jave code examples for showing how to use setSource() 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.
Example 1
Project: openjdk-jdk10   File: bug6583251.java   Source Code and License Vote up 6 votes
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
Project: OpenJSharp   File: XTextFieldPeer.java   Source Code and License Vote up 5 votes
@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 3
Project: jdk8u-jdk   File: XTextFieldPeer.java   Source Code and License Vote up 5 votes
@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
Project: jdk8u-jdk   File: bug6690791.java   Source Code and License Vote up 5 votes
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
Project: openjdk-jdk10   File: XTextFieldPeer.java   Source Code and License Vote up 5 votes
@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
Project: openjdk-jdk10   File: bug6690791.java   Source Code and License Vote up 5 votes
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);
}