Using Components, the GUI Building Blocks |
The Panel class is a general-purpose Container subclass. You can use it as-is to hold Components, or you can define a subclass to perform special functionality, such as event handling for the objects the Panel contains.The Applet class is a Panel subclass with special hooks to run in a browser or other applet viewer. Whenever you see a program that can run both as an applet and as an application, chances are that it defines an Applet subclass but doesn't use any of the special Applet capabilities, relying instead on the methods it inherits from the Panel class.
Here's an example of using a Panel instance to hold some Components:
[Point to more Panel subclass examples.]Panel p1 = new Panel(); p1.add(new Button("Button 1")); p1.add(new Button("Button 2")); p1.add(new Button("Button 3"));
Using Components, the GUI Building Blocks |