y****i 发帖数: 12114 | 1 正在学习用java进行简单画图,下面这个程序该怎么改?谢谢指教。
编译报错信息:
paintComponent(java.awt.Graphics) in javax.swing.JComponent cannot be
applied to (Graphics)
cannot find symbol method drawLine(int,int,int,int)
import java.awt.*;
import javax.swing.*;
import java.util.*;
public class Graphics extends JFrame {
private Paint newPaint= new Paint();
public Graphics()
{add(newPaint);
}
class Paint extends JPanel
{ public Paint(){};
// @Override
protected void paintComponent(Graphics g)
{ super.paintComponent(g);
g.drawLine(1,1,10,15);
}
}
public static void main(String[] arg)
{
JFrame frame=new Graphics();
frame.setVisible(true);
}
} | b***i 发帖数: 3043 | 2 你看到java有自己的class叫Graphics没
【在 y****i 的大作中提到】 : 正在学习用java进行简单画图,下面这个程序该怎么改?谢谢指教。 : 编译报错信息: : paintComponent(java.awt.Graphics) in javax.swing.JComponent cannot be : applied to (Graphics) : cannot find symbol method drawLine(int,int,int,int) : import java.awt.*; : import javax.swing.*; : import java.util.*; : public class Graphics extends JFrame { :
| y****i 发帖数: 12114 | |
|