1/**
2 * Copyright(C) 1998
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, 1998.
11 * @authorĀ : Salih Yurttas.
12 */
13
14
15import java.awt.*;
16
17import java.io.*;
18
19import sl.*;
20
21public class NameButton04 extends Frame {
22
23 public static void main(String[] args)
24 throws IOException
25 {
26 Frame f = new NameButton04();
27
28 f.setSize(400, 320);
29 f.show();
30 }
31
32 public NameButton04()
33 throws IOException
34 {
35 int[] iList = {2,
36 3,
37 1,
38 1,
39 2};
40 int NP = iList.length;
41
42 setLayout(new GridLayout(NP,1));
43
44 Panel[] pList = new Panel[NP];
45 int NB=0;
46 for(int i=0; i<NP; i++) {
47 NB += iList[i];
48 pList[i] = new Panel(new GridLayout(1,iList[i]));
49 }
50
51 StringList lList = new StringList(NB);
52 lList.getStringList();
53
54 Button[] bList = new Button[NB];
55 for(int i=0; i<NB; i++)
56 bList[i] = new Button(lList.getStringAt(i));
57
58 int bI=0,
59 eI=0;
60 for(int i=0; i<NP; i++) {
61 eI += iList[i];
62 makePanel(pList, i, bList, bI, eI);
63 add(pList[i]);
64 bI += iList[i];
65 }
66 }
67
68 public void makePanel(Panel[] pList,
69 int pIndex,
70 Button[] bList,
71 int bBIndex,
72 int bEIndex) {
73
74 for(int i=bBIndex; i<bEIndex; i++)
75 pList[pIndex].add(bList[i]);
76 }
77
78}