/ *试图画出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); //" "
}
}
答案 0 :(得分:0)
根据提供的小信息,我猜您需要指定backColor
的参数类型