1 package org.convey;
2 
3 import javax.swing.*;
4 import java.util.*;
5 import java.awt.event.*;
6 import java.awt.*;
7 
8 /**
9  * @author Ed Braunhut
10  * @version 0.3
11  */
12 public class ReportFrame extends JFrame{
13 
makebutton(String name, GridBagLayout gridbag, GridBagConstraints c)14   protected void makebutton(String name,
15                              GridBagLayout gridbag,
16                              GridBagConstraints c) {
17      Button button = new Button(name);
18      gridbag.setConstraints(button, c);
19      add(button);
20    }
21 
init()22    public void init() {
23      GridBagLayout gridbag = new GridBagLayout();
24      GridBagConstraints c = new GridBagConstraints();
25 
26      setFont(new Font("Helvetica", Font.PLAIN, 14));
27      setLayout(gridbag);
28 
29      c.fill = GridBagConstraints.BOTH;
30      c.weightx = 1.0;
31      makebutton("Button1", gridbag, c);
32      makebutton("Button2", gridbag, c);
33      makebutton("Button3", gridbag, c);
34 
35      c.gridwidth = GridBagConstraints.REMAINDER; //end row
36      makebutton("Button4", gridbag, c);
37 
38      c.weightx = 0.0;                  //reset to the default
39      makebutton("Button5", gridbag, c); //another row
40 
41      c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last in row
42      makebutton("Button6", gridbag, c);
43 
44      c.gridwidth = GridBagConstraints.REMAINDER; //end row
45      makebutton("Button7", gridbag, c);
46 
47      c.gridwidth = 1;                //reset to the default
48      c.gridheight = 2;
49      c.weighty = 1.0;
50      makebutton("Button8", gridbag, c);
51 
52      c.weighty = 0.0;                  //reset to the default
53      c.gridwidth = GridBagConstraints.REMAINDER; //end row
54      c.gridheight = 1;               //reset to the default
55      makebutton("Button9", gridbag, c);
56      makebutton("Button10", gridbag, c);
57 
58      setSize(300, 100);
59   }
60 }