import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class test1 extends Applet { GridBagLayout game; GridBagConstraints c; Canvas B1,B2; Canvas B3,B5; Canvas B12,PB12; Canvas BC; TextCanvas B4; Panel P1,P2,P12; Color BACK=Color.black; public void init() { game=new GridBagLayout(); c=new GridBagConstraints(); c.gridwidth=GridBagConstraints.REMAINDER; setLayout(game); setBackground(BACK); P1=new Panel(); P2=new Panel(); B1=new Canvas(); B2=new Canvas(); B3=new Canvas(); B4=new TextCanvas(); B5=new Canvas(); BC=new Canvas(); B1.resize(300,300); B2.resize(300,300); B3.resize(150,150); B4.resize(400,150); B5.resize(150,150); BC.resize(100,300); B1.setBackground(BACK); B2.setBackground(BACK); B1.setBackground(BACK); B2.setBackground(BACK); B3.setBackground(BACK); B4.setBackground(new Color(0,0,100)); B5.setBackground(BACK); P1.setBackground(Color.blue); P2.setBackground(Color.blue); BC.setBackground(new Color(0,0,100)); P1.add(B1); P1.add(BC); P1.add(B2); P2.add(B3); P2.add(B4); P2.add(B5); c.ipady=-5; game.setConstraints(P1,c); c.ipady=0; game.setConstraints(P2,c); add(P1); add(P2); } } class TextCanvas extends Canvas { Canvas C; TextCanvas() { this.C=C; } public void paint(Graphics g) { g.setFont(new Font("Helvetica",Font.PLAIN,40)); g.setColor(Color.yellow); g.drawString("Rich: Applet 11",10,40); g.setFont(new Font("Helvetica",Font.PLAIN,20)); g.drawString("Layout for Lucy and Lily",10,135); } }