enabled
这是错误:
TurtleGraphicsDemo2.java:19:错误:找不到符号
import java.awt.*;
public class TurtleGraphicsDemo2 {
public static void main(String[] args) {
World worldObj = new World();
Turtle myrtleTheTurtle = new Turtle(0, 0, worldObj);
drawLine(myrtleTheTurtle, Color.RED, 10, 20, 50, 20); //invokes the first drawLine() method
drawLine(myrtleTheTurtle, 100, 150, 50, -45); //invokes the second drawLine() method
drawLine(myrtleTheTurtle, 100, 150, 100, 60); //invokes the second drawLine() method
drawLine(myrtleTheTurtle, Color.BLUE, 10, 40, 100, 40); //invokes the first drawLine() method
}//end of main method
}//end of class
symbol:方法drawLine(Turtle,Color,int,int,int,int) location:class TurtleGraphicsDemo2
我的编程老师给了我们这个实验,但是我得到了一个drawLine错误,有人知道为什么吗?我没有太多Java经验,只有python。如果你可以解决这个问题,或者知道如何解决它,谢谢你。如果没有,无论如何都要感谢:)
答案 0 :(得分:1)
您可以使用 Graphics2D
在 Canvas 中绘制线条 class MyCanvas extends Canvas {
public MyCanvas () {
setBackground (Color.GRAY);
setSize(300, 300);
}
public void paint (Graphics g) {
Graphics2D g2;
g2 = (Graphics2D) g;
g2.drawString ("It is a custom canvas area", 70, 70);
}
}