:::::::::::::: DrawCanvas.java :::::::::::::: import java.awt.*; import java.applet.*; public class DrawCanvas extends Canvas { Graphics g; String curMode="Rect"; mPoint curObj; public boolean fill=true; mPoint objList[]=new mPoint[100]; int index=0; public DrawCanvas() { super(); setBackground(Color.blue); setForeground(Color.yellow); } public void setDrawMode(String s) { if(s.equals("Clear")) { index=0; repaint(); } else if(s.equals("Redraw")) repaint(); else curMode=s; } public void paint(Graphics g) { g.setColor(Color.yellow); super.paint(g); for(int i=0; i=100) index=100; return true; } }:::::::::::::: Paint.java :::::::::::::: import java.awt.*; import java.applet.*; public class Paint extends Applet { Label Status; DrawCanvas c; public void init() { setLayout(new BorderLayout()); setBackground(Color.gray); setForeground(Color.black); Panel w=new Panel(); w.setLayout(new GridLayout(7,0)); w.add(new Button("Rect")); w.add(new Button("Round")); w.add(new Button("Circ")); w.add(new Button("Line")); w.add(new Button("Draw")); w.add(new Button("Redraw")); w.add(new Button("Clear")); add("West", w); Status=new Label("Status Line"); Panel p=new Panel(); p.setBackground(Color.gray); p.add(Status); add("South",p); c=new DrawCanvas(); c.setBackground(Color.blue); add("Center", c); } public void paint(Graphics g) { c.paint(g); } public boolean action(Event evt, Object arg) { String s=(String) arg; if (evt.target instanceof Button) { Status.setText(((Button)evt.target).getLabel()); if (s.equals("Draw")) { ((Button)evt.target).setLabel("Fill"); c.fill=false; } else if (s.equals("Fill")) { ((Button)evt.target).setLabel("Draw"); c.fill=true; } else c.setDrawMode(s); } return true; } } :::::::::::::: mCircle.java :::::::::::::: import java.awt.*; import java.applet.*; public class mCircle extends mRectangle { public mCircle(int _x, int _y, int _x2, int _y2) { super(_x, _y, _x2, _y2); }; public void draw(Graphics g) { if (fill) { g.setColor(Color.black); g.fillOval(x, y, x2-x, y2-y); g.setColor(Color.yellow); } g.drawOval(x, y, x2-x, y2-y); } }:::::::::::::: mLine.java :::::::::::::: import java.awt.*; import java.applet.*; public class mLine extends mPoint { public mLine(int _x, int _y, int _x2, int _y2) { super(_x, _y, _x2, _y2); }; public void draw(Graphics g) { g.drawLine(x, y, x2, y2); } }:::::::::::::: mPoint.java :::::::::::::: import java.awt.*; import java.applet.*; public class mPoint extends Object { int x,y,x2,y2; boolean fill=false; public mPoint(int _x, int _y, int _x2, int _y2) { x=_x; y=_y; x2=_x2; y2=_y2; }; public void draw(Graphics g) { } public void setFill(boolean _fill) { fill=_fill; } public boolean isIn(int _x, int _y) { return true; } public void setEnds(int _x, int _y) { x2=_x; y2=_y; } }:::::::::::::: mRectangle.java :::::::::::::: import java.awt.*; import java.applet.*; public class mRectangle extends mPoint { public mRectangle(int _x, int _y, int _x2, int _y2) { super(_x, _y, _x2, _y2); }; public void draw(Graphics g) { if (fill) { g.setColor(Color.black); g.fillRect(x, y, x2-x, y2-y); g.setColor(Color.yellow); } g.drawRect(x, y, x2-x, y2-y); } public boolean isIn(int _x, int _y) { Rectangle r=new Rectangle(x, y, x2-x, y2-y); return r.inside(_x, _y); } }:::::::::::::: mRound.java :::::::::::::: import java.awt.*; import java.applet.*; public class mRound extends mPoint { public mRound(int _x, int _y, int _x2, int _y2) { super(_x, _y, _x2, _y2); }; public void draw(Graphics g) { if (fill) { g.setColor(Color.black); g.fillRoundRect(x, y, x2-x, y2-y, 100, 50); g.setColor(Color.yellow); } g.drawRoundRect(x, y, x2-x, y2-y, 100, 50); } }