home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java by Example
/
jbecd.bin
/
JBE-CD
/
NTUsers
/
JBECODE.ZIP
/
JavaByExample
/
chap22
/
GridBagApplet.java
< prev
next >
Wrap
Text File
|
1996-04-30
|
2KB
|
64 lines
import java.awt.*;
import java.applet.*;
public class GridBagApplet extends Applet
{
public void init()
{
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
GridBagConstraints constraints = new GridBagConstraints();
Button button1 = new Button("Button1");
Button button2 = new Button("Button2");
Button button3 = new Button("Button3");
Button button4 = new Button("Button4");
Button button5 = new Button("Button5");
Button button6 = new Button("Button6");
Button button7 = new Button("Button7");
Button button8 = new Button("Button8");
Button button9 = new Button("Button9");
constraints.fill = GridBagConstraints.BOTH;
layout.setConstraints(button1, constraints);
add(button1);
constraints.gridwidth = GridBagConstraints.RELATIVE;
layout.setConstraints(button2, constraints);
add(button2);
constraints.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(button3, constraints);
add(button3);
constraints.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(button4, constraints);
add(button4);
constraints.gridwidth = GridBagConstraints.RELATIVE;
layout.setConstraints(button5, constraints);
add(button5);
constraints.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(button6, constraints);
add(button6);
constraints.gridwidth = 1;
constraints.gridheight = 2;
layout.setConstraints(button7, constraints);
add(button7);
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.gridheight = 1;
layout.setConstraints(button8, constraints);
add(button8);
layout.setConstraints(button9, constraints);
add(button9);
resize(300, 200);
}
}