/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package newpackage;import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;/**
 *
 * @author Administrator
 */
public class Fuck extends JFrame {    public Fuck(Test test) {
        add(test);
    }    public static void main(String args[]) {
        Test test = new Test();
        Fuck fuck = new Fuck(test);
        fuck.setVisible(true); 
        fuck.setSize(400, 800);
        try {
            Thread.sleep(3000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        test.setxy(400, 400);  
        try {
            Thread.sleep(2000);
        } catch (Exception e) {
            e.printStackTrace();
        } 
        fuck.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}class Test extends JPanel {    int x = 100;
    int y = 200;
    int p = 300;
    int q = 700;    protected void paintComponent(Graphics g) {
        g.drawLine(x, y, p, q);
    }    public void setxy(int x1, int y1) {
        this.x = x1;
        this.y = y1;
        repaint();
    }
}为什么重画后原先的线没有被删除??