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 NameButton02 extends Frame {
22
23 public static void main(String[] args)
24 throws IOException
25 {
26 Frame f = new NameButton02();
27
28 f.setSize(400, 320);
29 f.show();
30 }
31
32 public NameButton02()
33 throws IOException
34 {
35 int[] iList = {2,
36 3,
37 1,
38 1};
39 int NP = iList.length;
40
41 setLayout(new GridLayout(NP,1));
42
43 Panel[] pList = new Panel[NP];
44 int NB=0;
45 for(int i=0; i<NP; i++) {
46 NB += iList[i];
47 pList[i] = new Panel(new GridLayout(1,iList[i]));
48 }
49
50 StringList lList = new StringList(NB);
51 lList.getStringList();
52
53 Button[] bList = new Button[NB];
54 for(int i=0; i<NB; i++)
55 bList[i] = new Button(lList.getStringAt(i));
56
57 int bI=0,
58 eI=0;
59 for(int i=0; i<NP; i++) {
60 eI += iList[i];
61 makePanel(pList,
62 i,
63 bList,
64 bI,
65 eI);
66 add(pList[i]);
67 bI += iList[i];
68 }
69 }
70
71 public void makePanel(Panel[] pList,
72 int pIndex,
73 Button[] bList,
74 int bBIndex,
75 int bEIndex) {
76
77 for(int i=bBIndex; i<bEIndex; i++)
78 pList[pIndex].add(bList[i]);
79 }
80
81}