problems with ClickMe Applet

I'm very new to Java and need help with a basic inquiry.

I have typed the following two sets of code from the java tuturial to run an applet where the user clicks and sees a red dot appear on the screen/

the code for ClickMe does not compile. The two errors I rcvd in terms of syntax do not make sense because I have verified again and again and the code is exactly as given in the tutorial. So I forcefully compile it using the set classpath= to get the ClickMe class. When I run the html file, I get error saying that it cannot find and load the ClickMe class.

Here are the two sets of code:

First file is called Spot:

import java.applet.Applet;

import java.awt.*;

import java.awt.event.*;

public class Spot{

public int size;

public int x, y;

public Spot(int intSize) {

size=intSize;

size=intSize;

x=-1;

y=-1;

}

}

This is the second java file ClickMe, I have used arrows to point to two lines where I get the error, the first is line 2 and the second is line 21.

import java.applet.Applet;

import java.awt.*;

import java.awt.event.*;

public class ClickMe extends Applet implements MouseListener{

private Spot spot=null; //<-error one points to this line

private static final int RADIUS=7;

public void init(){

addMouseListener(this);

}

public void paint(Graphics g){

g.setColor(Color.white);

g.fillRect(0,0,getSize().width- 1,getSize().height- 1);

g.setColor(Color.black);

g.drawRect(0,0,getSize().width- 1,getSize().height- 1);

g.setColor(Color.red);

if(spot!=null){

g.fillOval(spot.x - RADIUS,

spot.y - RADIUS,

RADIUS*2, RADIUS*2);

}

}

public void mousePressed(MouseEvent event){

if(spot==null){

spot=new Spot(RADIUS); /*<--Error 2 points to the capital "S" in Spot*/

}

spot.x=event.getX();

spot.y=event.getY();

repaint();

}

public void mouseClicked(MouseEvent event) {}

public void mouseReleased(MouseEvent event) {}

public void mouseEntered(MouseEvent event) {}

public void mouseExited(MouseEvent event) {}

}

Much appreciated if someone could take a look at this.

[2300 byte] By [dogara] at [2007-10-2 6:36:09]
# 1
You classpath is incorrect. At compile-time, while compiling the ClickMe class, it doesn't know where the Spot class is, because you haven't specified the classpath correctly.
warnerjaa at 2007-7-16 13:38:42 > top of Java-index,Java Essentials,New To Java...
# 2

> the code for ClickMe does not compile. The two errors

> I rcvd in terms of syntax do not make sense because I

> have verified again and again and the code is exactly

> as given in the tutorial. So I forcefully compile it

> using the set classpath= to get the ClickMe class.

There's nothing overly wrong with that. Most people would recommend using for example "javac -classpath . ClickMe.java"

> When I run the html file, I get error saying that it

> cannot find and load the ClickMe class.

>

You probably need to post the HTML code you are using. Make sure you have the .class files and the .html file in the same directory. Have you tried running the applet with appletviewer? ("appletviewer htmlfile.html")

atmguya at 2007-7-16 13:38:42 > top of Java-index,Java Essentials,New To Java...