home *** CD-ROM | disk | FTP | other *** search
/ Java by Example / jbecd.bin / JBE-CD / NTUsers / JBECODE.ZIP / JavaByExample / chap22 / GridBagApplet.java < prev    next >
Text File  |  1996-04-30  |  2KB  |  64 lines

  1. import java.awt.*;
  2. import java.applet.*;
  3.  
  4. public class GridBagApplet extends Applet
  5. {
  6.     public void init()
  7.     {
  8.         GridBagLayout layout = new GridBagLayout();
  9.         setLayout(layout);
  10.  
  11.         GridBagConstraints constraints = new GridBagConstraints();
  12.  
  13.         Button button1 = new Button("Button1");
  14.         Button button2 = new Button("Button2");
  15.         Button button3 = new Button("Button3");
  16.         Button button4 = new Button("Button4");   
  17.         Button button5 = new Button("Button5");
  18.         Button button6 = new Button("Button6");
  19.         Button button7 = new Button("Button7");
  20.         Button button8 = new Button("Button8");
  21.         Button button9 = new Button("Button9");
  22.    
  23.         constraints.fill = GridBagConstraints.BOTH;
  24.  
  25.         layout.setConstraints(button1, constraints);
  26.         add(button1);
  27.  
  28.         constraints.gridwidth = GridBagConstraints.RELATIVE;
  29.         layout.setConstraints(button2, constraints);
  30.         add(button2);
  31.  
  32.         constraints.gridwidth = GridBagConstraints.REMAINDER;
  33.         layout.setConstraints(button3, constraints);
  34.         add(button3);
  35.  
  36.         constraints.gridwidth = GridBagConstraints.REMAINDER;
  37.         layout.setConstraints(button4, constraints);
  38.         add(button4);
  39.     
  40.         constraints.gridwidth = GridBagConstraints.RELATIVE;
  41.         layout.setConstraints(button5, constraints);
  42.         add(button5);
  43.     
  44.         constraints.gridwidth = GridBagConstraints.REMAINDER;
  45.         layout.setConstraints(button6, constraints);
  46.         add(button6);
  47.     
  48.         constraints.gridwidth = 1;
  49.         constraints.gridheight = 2;
  50.         layout.setConstraints(button7, constraints);
  51.         add(button7);
  52.  
  53.         constraints.gridwidth = GridBagConstraints.REMAINDER;
  54.         constraints.gridheight = 1;
  55.         layout.setConstraints(button8, constraints);
  56.         add(button8);
  57.  
  58.         layout.setConstraints(button9, constraints);
  59.         add(button9);
  60.  
  61.         resize(300, 200);
  62.     }
  63. }
  64.