Previous | Next | Trail Map | Creating a User Interface | Using Components, the GUI Building Blocks


How to Use Panels

The Panel(in the API reference documentation)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(in the API reference documentation)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:

Panel p1 = new Panel();
p1.add(new Button("Button 1"));
p1.add(new Button("Button 2"));
p1.add(new Button("Button 3"));
[Point to more Panel subclass examples.]


Previous | Next | Trail Map | Creating a User Interface | Using Components, the GUI Building Blocks