Commit 78e6f022 authored by Daniel Vogel's avatar Daniel Vogel

small tweaks to event demos

parent 523ef3f6
......@@ -18,7 +18,7 @@ public class EventLoop extends JPanel {
EventLoop()
throws InterruptedException, InvocationTargetException {
EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
// enable events for this JPanel
// enable events for this JPanel
if (!isJava7Like()) setQueue();
EventQueue.invokeAndWait(new Runnable() {
......@@ -66,15 +66,16 @@ public class EventLoop extends JPanel {
// mouse events come in here
public void dispatchEvent(AWTEvent e) {
//System.out.println("dispatchEvent " + e.getID() );
if (e.getID() == MouseEvent.MOUSE_DRAGGED)
{
if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
MouseEvent me = (MouseEvent)e;
x = me.getX();
y = me.getY();
System.out.println("(" + x + "," + y + ")");
repaint();
}
repaint();
super.dispatchEvent(e);
}
// other kinds of events here
public void postEvent(AWTEvent e) {
//System.out.println("postEvent " + e.getID() );
......
......@@ -26,13 +26,11 @@ public class InheritanceEvents extends JPanel {
protected void processMouseMotionEvent(MouseEvent e)
{
// only detects when button is down WHILE also moving
if (e.getID() == MouseEvent.MOUSE_DRAGGED)
{
if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
x = e.getX();
y = e.getY();
repaint();
}
repaint();
}
int x;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment