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 aLayoutManager
ofFlowLayout
. - public Panel (LayoutManager layout)
- This constructor allows you to set the initial
LayoutManager
of the newPanel
tolayout
. Iflayout
isnull
, there is noLayoutManager
, and you must shape and position the components within thePanel
yourself.
- public void addNotify ()
- The
addNotify()
method creates thePanel
peer. If you override this method, first callsuper.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.