AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YDAT | YWAIT | Byzgraf | FAQs
FlowLayout typedict
 
A FlowLayout is a simple layout manager that arranges the components in a container in one or more rows in the same order that they appear in the container's layout array. Components should be AWT or Swing components, however all layout managers build a label appropriate for the container they are working on when they find a String in the layout array where they expected a component. Properties, like the font or foreground color, used by these short-hand labels can not be directly specified, so they are inherited from the container. A new row is started when a component will not fit at the end of the current row. The fields in a FlowLayout are:
alignment An int that controls the positioning of the components in the container. The value should be LEFT, CENTER, or RIGHT, which are defined in yoix.awt and yoix.swing.
hgap A double that represents the horizontal spacing between components in units of 72 dots per inch.
type A read-only int that is set to FLOWLAYOUT, which is defined in yoix.awt and yoix.swing.
vgap A double that represents the vertical spacing between components in units of 72 dots per inch.
A Panel uses FlowLayout as its default layout manager.
 
 Example:   The program,
import yoix.*.*;

Array alignments = {LEFT, CENTER, RIGHT};

Frame f = {
    FlowLayout layoutmanager = {
        int vgap = 72;
    };

    Array layout = {
        new Button {
            String text = "Align";

            actionPerformed(e) {
                int n = (100*random())%3;

                root.layoutmanager.alignment = alignments[n];
                root.layoutmanager = root.layoutmanager;   // do layout
            }
        },

        new Button {
            String text = "Shift";

            actionPerformed(e) {
                root.layoutmanager.hgap += 10;
                root.layoutmanager = root.layoutmanager;   // do layout
            }
        },

        new Button {
            String text = "Dismiss";

            actionPerformed(e) {
                exit(0);
            }
        },
    };
};

f.visible = TRUE;
adds three buttons to a frame that uses a FlowLayout as its layout manager. The program also shows how to modify layout manager fields and then have the changes show up as a new arrangement of the three buttons.
 
 See Also:   BorderLayout, BoxLayout, CardLayout, CustomLayout, GridBagLayout, GridLayout, LayoutManager

 

Yoix is a registered trademark of AT&T Intellectual Property.