这段代码有什么问题?为什么“<identifier> expected”显示为错误?

时间:2015-10-12 23:21:03

标签: graphics draw identifier

/ *试图画出Müller-Lyer  *幻觉使用图形* /

import javax.swing.*;
import java.awt.*;

public class MullerLyerIllusion extends JPanel{

public MullerLyerIllusion(backColor){
setBackground(backColor);
}

/ *图形显示,各种线段* /

public void paintComponent(Graphics g){
    super.paintComponent(g);
    g.setColor(Color.black);
    g.drawLine(100, 200, 400, 200); //first line segment
    g.drawLine(80, 180, 100, 200); // left-side arrow tail
    g.drawLine(80, 220, 100, 200); //"            "
    g.drawLine(400, 200, 420, 180); //right-side arrow tail
    g.drawLine(400, 200, 420, 220); //"           "
    g.drawLine(100, 400, 400, 400); //second line segment
    g.drawLine(100, 400, 120, 380); //left-side arrow head
    g.drawLine(100, 400, 120, 420); //"           "
    g.drawLine(380, 380, 400, 400); //right-side arrow head
    g.drawLine(380, 420, 400, 400); //"           "
  }

}

1 个答案:

答案 0 :(得分:0)

根据提供的小信息,我猜您需要指定backColor的参数类型