Hi, this patch makes AWTEvent's toString method follow the description from Java Class Libraries, 2nd Edition. It improves its comparability with JDK's output.
It also removes some unnecessary static methods from AWTEvent, and adapts EventQueue accordingly. Dalibor Topic
* libraries/javalib/java/awt/AWTEvent.java: (getID) removed unnecessary method. (getSource) removed unnecessary method. (toString) Improved compatibility with JDK. * libraries/javalib/java/awt/EventQueue.java: (dropAll) don't use static AWTEvent.getSource().
diff -urB kaffe/libraries/javalib/java/awt/AWTEvent.java patched-kaffe/libraries/javalib/java/awt/AWTEvent.java --- kaffe/libraries/javalib/java/awt/AWTEvent.java Mon Dec 17 11:54:51 2001 +++ patched-kaffe/libraries/javalib/java/awt/AWTEvent.java Tue Mar 12 15:35:31 2002 @@ -75,14 +75,6 @@ return id; } -static int getID ( AWTEvent evt ) { - return evt.id; -} - -static Object getSource ( AWTEvent evt ) { - return evt.source; -} - protected static Component getToplevel ( Component c ) { // Note that this will fail in case 'c' is already removeNotified (has no parent, // anymore). But returning 'null' would just shift the problem into the caller - @@ -146,7 +138,22 @@ } public String toString () { - return getClass().getName() + ':' + paramString() + ", source: " + source; + StringBuffer result = new StringBuffer(getClass().getName()); + + result.append('[').append(paramString()).append("] on "); + + Object src = getSource(); + if (src instanceof Component) { + result.append(((Component) src).getName()); + } + else if (src instanceof MenuComponent) { + result.append(((MenuComponent) src).getName()); + } + else { + result.append(src); + } + + return result.toString(); } static void unregisterSource ( Component c, Ptr nativeData ) { diff -urB kaffe/libraries/javalib/java/awt/EventQueue.java patched-kaffe/libraries/javalib/java/awt/EventQueue.java --- kaffe/libraries/javalib/java/awt/EventQueue.java Tue Mar 12 12:57:47 2002 +++ patched-kaffe/libraries/javalib/java/awt/EventQueue.java Tue Mar 12 15:58:12 2002 @@ -31,7 +31,7 @@ AWTEvent del, last = null; while ( e != null ) { - if ( AWTEvent.getSource( e) == source ) { + if ( e.getSource() == source ) { if ( localEnd == e ) localEnd = last;