我刚开始学JAVA,可以说一窍不通,还望各位前辈帮忙。
我在编译一个JAVA小程序时报了几个错误,应该是很简单的问题(以前编译过这个小程序,但没有报错过),请问这是什么问题?怎么解决??多谢~~~
小程序:
import java.*;
import java.applet.Applet;
/**Filledbox displays a filled,colored box in the browser window
*/
public class FilledBox extends Applet {
//This variable stores the color specified in the HTML document 
Color boxColor;
/**get the box color from the host HTML file
*/
public void init () {
String s;
s = getParameter("color");
//
boxColor = Color.gray;//
//
//
if (s != null) {
   if (s.equals("red")) boxColor = Color.red;
   if (s.equals("white")) boxColor = Color.white;
   if (s.equals("blue")) boxColor = Color.blue;
}
}
/**
*
*/
public void paint(Graphics g) {
g.setColor (boxColor);
g.fillRect (0,0,size().width,size().height);
}
}
编译时的报错:
--------------------Configuration: <Default>--------------------
E:\f\schen\java视频\JAVA\资料\JAVA代码\FilledBox.java:7: cannot resolve symbol
symbol  : class Color 
location: class FilledBox
Color boxColor;
^
E:\f\schen\java视频\JAVA\资料\JAVA代码\FilledBox.java:28: cannot resolve symbol
symbol  : class Graphics 
location: class FilledBox
public void paint(Graphics g) {
                  ^
E:\f\schen\java视频\JAVA\资料\JAVA代码\FilledBox.java:14: cannot resolve symbol
symbol  : variable Color 
location: class FilledBox
boxColor = Color.gray;
           ^
E:\f\schen\java视频\JAVA\资料\JAVA代码\FilledBox.java:20: cannot resolve symbol
symbol  : variable Color 
location: class FilledBox
   if (s.equals("red")) boxColor = Color.red;
                                   ^
E:\f\schen\java视频\JAVA\资料\JAVA代码\FilledBox.java:21: cannot resolve symbol
symbol  : variable Color 
location: class FilledBox
   if (s.equals("white")) boxColor = Color.white;
                                     ^
E:\f\schen\java视频\JAVA\资料\JAVA代码\FilledBox.java:22: cannot resolve symbol
symbol  : variable Color 
location: class FilledBox
   if (s.equals("blue")) boxColor = Color.blue;
                                    ^
Note: E:\f\schen\java视频\JAVA\资料\JAVA代码\FilledBox.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
6 errorsProcess completed.