June 2002
Beginner to intermediate
640 pages
14h 24m
English
Panels allow you to organize portions of a larger user interface within a frame, a dialog, or a window. Like frames (java.awt.Frame and javax.swing.JFrame), panels extend the java.awt.Container class, which means that they can contain other components. However, they can't exist on their own but must be in the context of a window, dialog, or frame, or in the context of another panel contained in a top-level window (like Dialog, Frame, or Window).
Here's a JFC/Swing example of adding components with JPanel, in which every time the Add button is pressed another button is added to a panel. Import JPanel and JFrame from the javax.swing package.
>>> from javax.swing import JPanel, JFrame, JButton
Create a frame variable in the global space ...
Read now
Unlock full access