StackLayout Demonstration and Test

To demonstrate StackLayout's operation we pop up a (java) Frame. This Applet is admittedly very ugly. That is not the point. The point is to show how the various layout tags affect the positioning of gui widgets.

Resize the frame in both width and height to see how the components are arranged to use the available space.

With StackLayout you basically arrange a horizontal or vertical sequence of components by telling how to place them in sequence. You compose a more complicated screen by, say, stacking a vertical sequence (using the vertical layout) of panels, each of which use the horizontal layout. You might write something like this:

    setLayout(new StackLayout(StackLayout.HORIZONTAL));
    p.add("Left",new Button("Left"));
    p.add("Right",new Button("Right"));
The positioning/sizing tag is composed of the following keywords:
  "Center"                : centered horizontally & vertically (the default)
  "Left"    or "Top"      : pushed at the left|top edge.
  "Right"   or "Bottom"   : pushed against the right|top edge
  "Wide"    or "Tall"     : filled to use available space.
  "Wide*#"  or "Tall*#"   : filled but weighted by the number #.
  "Fill" (or "Fill*#")    : filled in both directions.
  "Width=#" or "Height=#" : given explicit width|height
  "Flush"                 : margins are not added around this component.

Created by Bruce Miller @ NIST ( Disclaimer.