O'Reilly logo

Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython by Richard Hightower

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling Events with JFrame

Since Frame is a subclass of java.awt.Frame, which is a subclass of java.awt.Window, you can listen for window events with its event mechanism. Import the jinfo class to inspect the event properties of Frame (JFrame's superclass).

>>> import jinfo
>>> from java.awt import Frame
>>> jinfo.getEventsInfo(Frame)
[]

As you can see, Frame has no event properties, because its events are defined from its base class, java.awt.Window.

>>> Frame.superclass
<jclass java.awt.Window at 228949474>

Therefore, we need to inspect Window's event properties.

 >>> jinfo.getEventsInfo(Window) [<beanEventProperty windowIconified for event interface java.awt.event.WindowListener at 861240813>, <beanEventProperty WindowActivated for event ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required