List of usage examples for java.awt EventQueue peekEvent
public AWTEvent peekEvent()
From source file:Main.java
public Point getClick() { EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue(); while (true) { try {/*from w ww .j a v a 2 s . c o m*/ AWTEvent pEvent = eq.peekEvent(); AWTEvent evt = eq.getNextEvent(); if (evt.getID() == MouseEvent.MOUSE_PRESSED) { MouseEvent mevt = (MouseEvent) evt; Point p = mevt.getPoint(); Point top = getRootPane().getLocation(); p.x -= top.x; p.y -= top.y; return p; } } catch (InterruptedException e) { } } }