Java Event Parameters


About:

An event callback script can query the event parameters using the java::event command. Usually, there is only one event parameter -- the event object, which stores various information about the event as its properties. For example, when the mouseClicked event occurs inside an AWT Button, the x and y properties of the event object contains the location of the mouse cursor. The following script prints out the location of the mouse cursor:

Example:

package require java

set f [java::new java.awt.Frame]
$f setSize 100 100
$f show

java::bind $f mouseClicked {
    puts "mouse click at ([java::event x],[java::event y])"
}

Copyright © 1997-1998 Sun Microsystems, Inc.