Yurttas/PL/OOL/Java/F/05/01/01/02/GLJButtons00.java

 1/**
 2 *  Copyright(C) 2002
 3 *  All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4 *
 5 *  Permission to use, copy, modify, and distribute this
 6 *  software and its documentation for EDUCATIONAL purposes
 7 *  and without fee is hereby granted provided that this
 8 *  copyright notice appears in all copies.
 9 *
10 *  @date   : January 1, 2002.
11 *  @authorĀ : Salih Yurttas.
12 */
13
14
15import javax.swing.*;
16
17import java.awt.*;
18
19public class GLJButtons00 extends JFrame {
20
21  public static void main(String[] args) {
22    JFrame jF = new GLJButtons00();
23
24    jF.setSize(400,320);
25    jF.setVisible(true);
26  }
27
28  private String[] bLabels = {"One",
29                              "Two",
30                              "Three"};
31  private int n = bLabels.length;
32
33  private JButton[] jB;
34
35  public GLJButtons00() {
36    setTitle("GLJButtons00");
37
38    GridLayout gL = new GridLayout();
39    this.getContentPane().setLayout(gL);
40
41    jB = new JButton[n];
42
43    for(int i=0; i<n; ++i) {
44      jB[i] = new JButton(bLabels[i]);
45      this.getContentPane().add(jB[i]);
46    }
47  }
48
49}