以下的代码运祥正常,运行的时候,有按钮和直线出现,
但是当我想将其中的画图代码
public void paint(Graphics g)
{
                  super.paint(g);
g.drawLine(20,20,50,100); }
替换为:
   public void paintpaintComponent(Graphics g)
   {
   super.paintComponents(g);
   g.drawLine(20,20,50,100);   (说明;其中的super.paintComponents(g);我想应该是super.paintComponent(g);,也就是不能  代"s"的,但是我在super后面打上"."后,程序只有paintComponents(g)供我选择,没有paintComponent(g);)    }
其他的一切都不变,请问,运行的时候,这条直线就画不出来了
请问这是怎么回事呢?paintComponent()需要在什么情况下使用呢?
谢谢!代码如下;import java.awt.*;
import javax.swing.*;public class Test extends JApplet
{
JTextField xfield1 ;
JLabel xLabel1 ;
Container con;
public void init()
{
con=getContentPane();
con.setLayout(new FlowLayout());
xfield1 = new JTextField(6);
xLabel1 = new JLabel("请输入X1坐标");
con.add(xLabel1);
         con.add(xfield1);
    
}
public void paint(Graphics g)
{
                  super.paint(g);
g.drawLine(20,20,50,100); }
}