Im trying to build my first applet but im totally lost. I cant understand what ive done wrong. I want to be able to select a choice(circle,square,etc and click on a button which draws that object on my canvas but imlost.Can some1 please help. Here is my code in full...
//import classes
import java.awt.*;
import java.io.*;
import java.lang.*;
import java.net.URL;
import java.util.*;
import java.awt.Color;
import java.applet.*;

//Java Applet of Objects
public class Objects extends Applet
{
ObjectsControls controls;
ObjectsCanvas canvas;
int c;

//initialise border,controls(add to Pane)
public void init()
{
setLayout(new BorderLayout());
ObjectsCanvas c = new ObjectsCanvas();
add("Center", c);
add("North", controls = new ObjectsControls(c));
}

//start controls
public void start()
{
controls.start();
}

//stop controls
public void stop()
{
controls.stop();
}

//initialise frame with objects
public static void main(String args[])
{
Frame f = new Frame("Objects");
Objects objects = new Objects();

objects.init();
objects.start();

f.add("Center", objects);
f.resize(550,600 );
f.show();
}
}

/********************************
* - Applet Canvas - *
* paint method *
* (objects and canvas) *
********************************/


class ObjectsCanvas extends Canvas
{
boolean submit = false;
int noob = 0;
int obj = 0;
Objects objects;
ObjectsControls controls;

public void add(Objects object){}
//paint method
public void paint(Graphics g)
{
this.white(g);
}


public void update(Graphics g)
{
if (!submit)this.white(g);
else
{
if (noob == 0)
{
this.oval(g,obj);
}
else if (noob == 1)
{
this.rect(g,obj);
}
else if (noob == 2)
{
this.square(g,obj);
}
else
{
this.triangle(g,obj);
}
}
}

//canvas(draw objects)
public void white(Graphics g)
{
g.setColor(Color.white);
g.fillRect(10,10,500,280);
g.setColor(Color.black);
g.drawRect(10,10,500,280);
}

//object oval
public void oval(Graphics g,int obj)
{
g.setColor(Color.red);
g.fillOval(30,30,20,20);
}

//object rectangle
public void rect(Graphics g,int obj)
{
g.setColor(Color.blue);
g.fillRect(50,50,400,220);
}

//object square
public void square(Graphics g,int obj)
{
g.setColor(Color.green);
g.fillSquare(25,25,25,25);
}

//object triangle
public void triangle(Graphics g,int obj)
{
g.setColor(Color.yellow);
g.fillTriangle(10,10);
}

public void getdata(int noob)
{
this.noob = noob;
}

public void redraw(boolean submit)
{
this.submit = submit;
repaint();
}
}

/********************************
* - Applet Controls - *
* creating controls *
* action method *
********************************/

class ObjectsControls extends Panel
{
int o,obj;
ObjectsCanvas canvas;

//add object controls
public ObjectsControls(ObjectsCanvas canvas)
{
this.canvas = canvas;

Choice o = new Choice();
o.addItem("Circle");
o.addItem("Rectangle");
o.addItem("Square");
o.addItem("Triangle");
add(o);

add(new Button("submit"));
add(new Button("clear"));
}

//action method
public boolean action(Event e, Object arg)
{
if (e.target instanceof Choice)
{
String label = (String)arg;

if (label.equals("Circle"))
o=0;
else if (label.equals("Rectangle"))
o=1;
else if (label.equals("Square"))
o=2;
else
o=3;

canvas.getdata(o);
return true;
}
else if(e.target instanceof Button)
{
String label = (String)arg;
canvas.redraw(label.equals("submit"));
return true;
}
return false;
}

//start actions
public void start()
{
this.enable();
}

//stop actions
public void stop()
{
this.disable();
}
}