home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Java AWT

Previous Chapter 6
Containers
Next
 

6.2 Panel

The Panel class provides a generic container within an existing display area. It is the simplest of all the containers. When you load an applet into Netscape Navigator or an appletviewer, you have a Panel to work with at the highest level.

A Panel has no physical appearance. It is just a rectangular display area. The default LayoutManager of Panel is FlowLayout; FlowLayout is described in FlowLayout.

Panel Methods

Constructors

public Panel ()

The first constructor creates a Panel with a LayoutManager of FlowLayout.

public Panel (LayoutManager layout) (New)

This constructor allows you to set the initial LayoutManager of the new Panel to layout. If layout is null, there is no LayoutManager, and you must shape and position the components within the Panel yourself.

Miscellaneous methods

public void addNotify ()

The addNotify() method creates the Panel peer. If you override this method, first call super.addNotify(), then add your customizations for the new class. Then you can do everything you need with the information about the newly created peer.

Panel Events

In Java 1.0, a Panel peer generates all the events that are generated by the Component class; it does not generate events that are specific to a particular type of component. That is, it generates key events, mouse events, and focus events; it doesn't generate action events or list events. If an event happens within a child component of a Panel, the target of the event is the child component, not the Panel. There's one exception to this rule: if a component uses the LightweightPeer (new to Java 1.1), it cannot be the target of an event.

With Java 1.1, events are delivered to whatever listener is associated with a contained component. The fact that the component is within a Panel has no relevance.


Previous Home Next
Container Book Index Insets

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java