< prev index next >

src/java.desktop/share/classes/java/awt/GridLayout.java

Print this page




  38  * import java.awt.*;
  39  * import java.applet.Applet;
  40  * public class ButtonGrid extends Applet {
  41  *     public void init() {
  42  *         setLayout(new GridLayout(3,2));
  43  *         add(new Button("1"));
  44  *         add(new Button("2"));
  45  *         add(new Button("3"));
  46  *         add(new Button("4"));
  47  *         add(new Button("5"));
  48  *         add(new Button("6"));
  49  *     }
  50  * }
  51  * </pre></blockquote><hr>
  52  * <p>
  53  * If the container's {@code ComponentOrientation} property is horizontal
  54  * and left-to-right, the above example produces the output shown in Figure 1.
  55  * If the container's {@code ComponentOrientation} property is horizontal
  56  * and right-to-left, the example produces the output shown in Figure 2.
  57  *
  58  * <table style="float:center;width:600" summary="layout">

  59  * <tr style="text-align:center">
  60  * <td><img SRC="doc-files/GridLayout-1.gif"
  61  *      alt="Shows 6 buttons in rows of 2. Row 1 shows buttons 1 then 2.
  62  * Row 2 shows buttons 3 then 4. Row 3 shows buttons 5 then 6.">
  63  * </td>
  64  *
  65  * <td style="text-align:center"><img SRC="doc-files/GridLayout-2.gif"
  66  *              alt="Shows 6 buttons in rows of 2. Row 1 shows buttons 2 then 1.
  67  * Row 2 shows buttons 4 then 3. Row 3 shows buttons 6 then 5.">
  68  * </td>
  69  * </tr>
  70  *
  71  * <tr style="text-align:center">
  72  * <td>Figure 1: Horizontal, Left-to-Right</td>
  73  *
  74  * <td>Figure 2: Horizontal, Right-to-Left</td>
  75  * </tr>
  76  * </table>
  77  * <p>
  78  * When both the number of rows and the number of columns have




  38  * import java.awt.*;
  39  * import java.applet.Applet;
  40  * public class ButtonGrid extends Applet {
  41  *     public void init() {
  42  *         setLayout(new GridLayout(3,2));
  43  *         add(new Button("1"));
  44  *         add(new Button("2"));
  45  *         add(new Button("3"));
  46  *         add(new Button("4"));
  47  *         add(new Button("5"));
  48  *         add(new Button("6"));
  49  *     }
  50  * }
  51  * </pre></blockquote><hr>
  52  * <p>
  53  * If the container's {@code ComponentOrientation} property is horizontal
  54  * and left-to-right, the above example produces the output shown in Figure 1.
  55  * If the container's {@code ComponentOrientation} property is horizontal
  56  * and right-to-left, the example produces the output shown in Figure 2.
  57  *
  58  * <table style="float:center;width:600">
  59  * <caption style="display:none">Figures</caption>
  60  * <tr style="text-align:center">
  61  * <td><img SRC="doc-files/GridLayout-1.gif"
  62  *      alt="Shows 6 buttons in rows of 2. Row 1 shows buttons 1 then 2.
  63  * Row 2 shows buttons 3 then 4. Row 3 shows buttons 5 then 6.">
  64  * </td>
  65  *
  66  * <td style="text-align:center"><img SRC="doc-files/GridLayout-2.gif"
  67  *              alt="Shows 6 buttons in rows of 2. Row 1 shows buttons 2 then 1.
  68  * Row 2 shows buttons 4 then 3. Row 3 shows buttons 6 then 5.">
  69  * </td>
  70  * </tr>
  71  *
  72  * <tr style="text-align:center">
  73  * <td>Figure 1: Horizontal, Left-to-Right</td>
  74  *
  75  * <td>Figure 2: Horizontal, Right-to-Left</td>
  76  * </tr>
  77  * </table>
  78  * <p>
  79  * When both the number of rows and the number of columns have


< prev index next >