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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.