请帮忙改正这个JAVA小程序
照书打的,不知道怎样有错了。。。importjava.awt.*;publicclassFancyPicture{/***@paramargs*/publicstatic...
照书打的,不知道怎样有错了。。。
import java.awt.*;
public class FancyPicture{
/**
* @param args
*/
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(250.220);
Graphics 2D g2 = panel.getGraphics();
g2.translate(100,120);
g2.fillRect(-5,-5,10,10);
for(int i=0 ; i<=12 ;i++){
g2.setColor(Color.BLUE);
g2.fillRect(20,20,20,20);
g2.setColor(Color.BLACK);
g2.drawString(" "+i,20,20);
g2.rotate(Math.toRadian(30));
g2.scale(1.1,1.1);
}
}
}
=====================
以下是错误提示:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
DrawingPanel cannot be resolved to a type
DrawingPanel cannot be resolved to a type
Syntax error on token "2D", delete this token
The method toRadian(int) is undefined for the type Math
The method scale(double, double) is undefined for the type Graphics
at FancyPicture.main(FancyPicture.java:9) 展开
import java.awt.*;
public class FancyPicture{
/**
* @param args
*/
public static void main(String[] args) {
DrawingPanel panel = new DrawingPanel(250.220);
Graphics 2D g2 = panel.getGraphics();
g2.translate(100,120);
g2.fillRect(-5,-5,10,10);
for(int i=0 ; i<=12 ;i++){
g2.setColor(Color.BLUE);
g2.fillRect(20,20,20,20);
g2.setColor(Color.BLACK);
g2.drawString(" "+i,20,20);
g2.rotate(Math.toRadian(30));
g2.scale(1.1,1.1);
}
}
}
=====================
以下是错误提示:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
DrawingPanel cannot be resolved to a type
DrawingPanel cannot be resolved to a type
Syntax error on token "2D", delete this token
The method toRadian(int) is undefined for the type Math
The method scale(double, double) is undefined for the type Graphics
at FancyPicture.main(FancyPicture.java:9) 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询