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 ...

Get Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.