home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / linux / lg / issue29 / HAMILTON / Form.java < prev    next >
Encoding:
Java Source  |  1998-01-24  |  1.7 KB  |  36 lines

  1. package Jcd;   // -- Listing-2 -- Form.java  //  1
  2.                                              //  2
  3. import java.awt.*;                           //  3
  4.                                              //  4
  5. public class Form extends Frame {            //  5
  6.                                              //  6
  7.  // Subclass the AWT GridBagLayout Frame by adding
  8.  // methods to set up placement constraints.     
  9.                                              //  9
  10.   public GridBagLayout layout;               // 10
  11.                                              // 11
  12.   protected Insets formInsets=new Insets(1,1,1,1);
  13.                                              // 13
  14.   public Form(String title)                  // 14
  15.   {                                          // 15
  16.     super(title);                            // 16
  17.     layout = new GridBagLayout();            // 17
  18.     setLayout(layout);                       // 18
  19.   }                                          // 19
  20.                                              // 20
  21.   public Component addCenter(Component comp) // 21
  22.   {                                          // 22
  23.     int fill = GridBagConstraints.NONE;      // 23
  24.     Insets insets = formInsets;              // 24
  25.     GridBagConstraints c=new GridBagConstraints();
  26.     c.gridx = 0;                             // 26
  27.     c.gridy = GridBagConstraints.RELATIVE;   // 27
  28.     c.anchor = GridBagConstraints.CENTER;    // 28
  29.     c.gridwidth = GridBagConstraints.REMAINDER;
  30.     c.fill = fill;                           // 30
  31.     c.insets = insets;                       // 31
  32.     layout.setConstraints(comp, c);          // 32
  33.     return super.add(comp);                  // 33
  34.   }                                          // 34
  35. }                                            // 35
  36.