Low Level Event Handling import java.awt.*; import java.applet.*; import java.awt.event.*; class CBG extends Checkbox{ cbgb CB; CBG(String s, CheckboxGroup c, boolean b, cbgb cb) { super(s, c, b); CB=cb; enableEvents(AWTEvent.ITEM_EVENT_MASK); } public void processItemEvent(ItemEvent i){ CB.s=CB.cg.getSelectedCheckbox().getLabel(); CB.repaint(); } } public class cbgb extends Applet{ CheckboxGroup cg; CBG a, b, c, d, e, f; String s; public void init(){ setBackground(Color.yellow); cg = new CheckboxGroup(); a = new CBG("Checkers", cg, false, this); b = new CBG("Polka Dots", cg, false, this); c = new CBG("Stripes", cg, false, this); d = new CBG("Solid", cg, true, this); e = new CBG("Diamonds", cg, false, this); f = new CBG("Donuts", cg, false, this); add(a); add(b); add(c); add(d); add(e); add(f); s="Solid"; } public void paint(Graphics g){ g.setColor(Color.black); if(s.equals("Solid")) {} else if(s.equals("Checkers")){ for(int x=20; x<180; x+=40) for(int y=80; y<240; y+=40){ g.fillRect(x,y,20,20); g.fillRect(x+20,y+20,20,20); } } else if(s.equals("Donuts")){ for(int x=20; x<180; x+=40) for(int y=80; y<240; y+=40){ g.setColor(Color.black); g.fillOval(x,y,30,30); g.setColor(Color.yellow); g.fillOval(x+10,y+10,10,10); } } else if(s.equals("Stripes")){ for(int y=80; y<240; y+=10){ g.fillRect(20,y,160,5); } } else if(s.equals("Diamonds")){ for(int x=20; x<180; x+=40) for(int y=80; y<240; y+=40){ int pxs[] = {x, x+10, x, x-10}; int pys[] = {y, y+10, y+20, y+10}; g.fillPolygon(pxs, pys, 4); } } else if(s.equals("Polka Dots")){ for(int x=20; x<180; x+=40) for(int y=80; y<240; y+=40){ g.setColor(Color.red); g.fillOval(x-5,y+10,12,12); g.setColor(Color.blue); g.fillOval(x+10, y, 18,18); g.setColor(Color.magenta); g.fillOval(x-5, y+20, 24,24); g.setColor(Color.green); g.fillOval(x-5, y-10, 20,20); } } } } //