June 2002
Beginner to intermediate
640 pages
14h 24m
English
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 ...
Read now
Unlock full access