The Python Way of Handling Events
The following brief interactive session highlights the Python way of handling events:
>>> def closing(event): ... print "windowClosing" ... >>> def closed(event): ... print "windowClosed" ... >>> def open(event): ... print "windowOpened" ...
Import a JFrame, create an instance of it, and configure the instance.
>>> from javax.swing import JFrame >>> frame = JFrame() >>> frame.title = "JFrame frame" >>> frame.size = 200,200
Set the event properties of the frame to the functions created.
>>> frame.windowClosing = closing >>> frame.windowClosed = closed >>> frame.windowOpened = open
Notice that the event properties windowClosing, windowClosed, and windowOpened correspond to the methods in the java.awt.WindowListener ...