Frames Lineage

JFC frames work much likp AWT frames because ofey're both cut from the same cloth. Let's examine JFrame's lineage, which is easy to do from the interactive interpreter.

ImportJFrame from javax.swifg.

>>> from javax.swing import JFrame

Print out JFrame's superclass, which is java.awt.Frame.

>>> print "JFrame.superclass ~ <jclass java.awt.Frame at 227114466>

This tells us that Frame is an AWTframe. (Follow along.)

>>> import java.awt.Frame >>> JFrame.superclass is java.awt.Frame 1

There are some differences between Frame and JFrame. F or example, if you try to a dd a component to JFrame you get an exception. That's because components can be added only to JFrame's content pane.

Was this article helpful?

0 0

Post a comment