/*
03.16.00
Jim Roberts
Widgets -- GridLayout with internal Border and Grid Layouts
*/
import java.awt.*; x x
import java.applet.Applet;
public class Widgets extends Applet
{
Font f;
Button b1, b2, b3, b4, b5, b6;
TextField t1;
Label l1, l2, l3;
Panel panelR1C2; // for the 1st row, 2nd column position
Panel panelR2C1;
Panel panelR3C1;
public void init( )
{
setBackground(Color.yellow);
setLayout(new GridLayout( 3, 2, 10, 25));
f = new Font("Serrif", Font.BOLD, 18);
b1 = new Button("Button 1");
b2 = new Button("Button 2");
b2.setFont(f);
b3 = new Button("Button 3");
b3.setFont(f);
b3.setBackground(Color.red);
b3.setForeground(Color.white);
b4 = new Button("Button 4");
b5 = new Button("Button 5");
b5.setFont(f);
b6 = new Button("Button 6");
b6.setFont(f);
b6.setBackground(Color.red);
b6.setForeground(Color.white);
t1 = new TextField();
t1.setBackground(Color.green);
t1.setText("This is a text input field");
l1 = new Label("Left Justified", Label.LEFT);
l1.setFont(f);
l1.setBackground(Color.red);
l1.setForeground(Color.white);
l2 = new Label("Center Justified", Label.CENTER);
l2.setFont(f);
l2.setBackground(Color.red);
l2.setForeground(Color.white);
l3 = new Label("Right Justified", Label.RIGHT);
l3.setFont(f);
l3.setBackground(Color.red);
l3.setForeground(Color.white);
panelR1C2 = new Panel();
panelR1C2.setBackground(Color.cyan);
panelR1C2.setLayout(new GridLayout(3,1,5,5));
panelR1C2.add(b1);
panelR1C2.add(b2);
panelR1C2.add(b3);
panelR2C1 = new Panel();
panelR2C1.setBackground(Color.pink);
panelR3C1 = new Panel();
panelR3C1.setBackground(Color.orange);
panelR3C1.setLayout(new BorderLayout(5,5));
panelR3C1.add(BorderLayout.NORTH, b4);
panelR3C1.add(BorderLayout.EAST, b5);
panelR3C1.add(BorderLayout.SOUTH, b6);
panelR3C1.add(BorderLayout.WEST, l1);
add(t1);
add(panelR1C2);
add(panelR2C1);
add(l2);
add(panelR3C1);
add(l3);
}
}