Introduction
Containers Layouts Widgets Miscellaneous

Containers -> panel

A panel is an area which is a container of other widgets. It is where buttons, lists, comboboxes, or even another panel, etc. are added. A layout can be specified for a panel. At the same time, a panel can also be considered a widget or a component (in jIRCii sense). You may say that a panel is a widget that can contain other widgets.

The snippet below shows how to create a panel:

$panel = panel('layout=Flow');

See the layout section for more explanation.

The first parameter can also be a frame. This is because, frames already have a "default" panel where you can immediately add components. So instead of creating a "main" panel, it is better to "extract" the already existing main panel of a frame. The snippet below shows how to do this:

$panel = panel($an_existing_frame_or_dialog, 'layout=flow');

The above snippet means "extract the panel from $an_existing_frame_or_dialog and name it $panel, and set its layout to FlowLayout".

In a jIRCii script, a panel would be created as such:

$f = frame("Title", "size=220 120");
$p = panel($f, "layout=border");
# Add widgets/components to $p using add();
show($f);

For Java programmers, the above jIRCii/Sleep snippet would be more or less similar to the snippet below:

JFrame f = new JFrame("Title");
f.setSize(220, 120);
Container p = f.getContentPane();
p.setLayout(new BorderLayout());
// Add components to p
f.show();

It is alright to create a new panel altogether and add it to the frame. This can be done like this:

$f = frame("Title", "size=300 300");
$p = panel("layout=border");
# In Java, the above line translates to:
# JPanel p = new JPanel(new BorderLayout());

add($f, $p);
show($f);

However, it is HIGHLY recommended that the existing panel of a frame should be used as the main container of a frame. It is much more efficient to do so.

To summarize, if the first parameter of panel() is a frame or a dialog, you will get the default or existing content panel of that frame or dialog. Then you don't need to add() the panel to your frame. If no frame or dialog is specified, then it is a new panel and it MUST be added to the main panel.

Syntax and properties

$panel = panel([$frame or $dialog , properties]);

Even without any parameters, a panel with a null layout will be created. Thus, the line below is perfectly valid.

$panel = panel();

Panel properties

NameArgumentsDescExample
layout name [args] "name" stands for the layout type and [args]. See layouts for more info. $p = panel($some_frame, 'layout=grid 3 3');
size w h This specifies the (w)idth and (h)eight of the panel. $p = panel('size=100 85');
color COLORNAME This specifies the color of the panel. See color section for more info on available colors. $p = panel('color=DARK_GRAY');

These properties are optional and can be in any order.

- End of page -
Hosted by www.Geocities.ws

1