Class Reading Help.

Hello, I'm new here. I have a problem that I can't read from another class I have created. I am a student, using a glencoe book titled "Introduction to Computer Science Using JAVA". I am on an exerscise learning about colors. What I did was I created a java file, titles "FancyText1" with the code.

import java.awt.*;

publicclass FancyText1

{

publicvoid drawRed(Graphics g, String displayString)

{

g.setColor(Color.red);

g.drawString(displayString, 100, 100);

}

publicvoid drawBlue(Graphics g, String displayString)

{

g.setColor(Color.blue);

g.drawString(displayString, 100, 120);

}

}

then I compiled it and it complied without an error.

Next I created the java file that reads from it.

import java.awt.*;

import javax.swing.*;

publicclass FancyText1Testerextends JApplet

{

publicvoid paint(Graphics g)

{

FancyText1 ft1 =new FancyText1();

ft1.drawBlue(g,"MOO");

ft1.drawRed(g,"MOO");

}

}

this file is named "FancyText1Tester.java".

When I try to compile this, I get an error.

C:\j2sdk1.4.2_05\SourceTyrel\FancyText\Fancy\FancyText1Tester.java:8: cannot resolve symbol

symbol :class FancyText1

location:class FancyText1Tester

FancyText1 ft1 =new FancyText1();

^

C:\j2sdk1.4.2_05\SourceTyrel\FancyText\Fancy\FancyText1Tester.java:8: cannot resolve symbol

symbol :class FancyText1

location:class FancyText1Tester

FancyText1 ft1 =new FancyText1();

^

2 errors

what does this mean?

If I type the code Like this...

import java.awt.*;

import javax.swing.*;

publicclass FancyText1Testerextends JApplet

{

publicvoid drawRed(Graphics g, String displayString)

{

g.setColor(Color.red);

g.drawString(displayString, 100, 100);

}

publicvoid drawBlue(Graphics g, String displayString)

{

g.setColor(Color.blue);

g.drawString(displayString, 100, 120);

}

publicvoid paint(Graphics g)

{

drawRed(g,"Red Fish");

drawBlue(g,"Blue Fish");

}

}

and name the file "FancyText1Tester.java" it compiles. Why can I not read the FancyText1.class?

[3950 byte] By [SangreFiraga] at [2007-9-30 21:56:45]
# 1

Your code is fine, probably your CLASSPATH variabile is not setted correctly

Try this:

1) create a directory on your C harddrive called (for example) obj

2) type: set CLASSPATH=c:\obj

3) Compile the FancyText1 source:

javac -d c:\obj FancyText1.java

4) Compile the FancyText1Tester source

javac -d c:\obj FancyText1Tester.java

Good luck.

sils at 2007-7-7 3:24:39 > top of Java-index,Archived Forums,Debugging Tools and Techniques...
# 2

both these classes should be in a package.

// example

package myTest.awt.package;

this package statement should be the first statement in ur java class even before the imports so that both the classes are visible to each other..

s

sienfield at 2007-7-7 3:24:39 > top of Java-index,Archived Forums,Debugging Tools and Techniques...