我在做一个字体移动的程序
但是他总是有影子留在上面 能有什么办法消掉吗 ?
下面是代码 :
package PackageMain;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class Remove extends JFrame {
private int WIDTH = 5;
public Remove() {
this.setSize(300,200);
this.setVisible(true);
}
public void paint(Graphics g) {
g.drawString("Hello",WIDTH,100);
}
public void Try () {
Thread th = new Thread();
th.start();
while(true) {
WIDTH += 30;
try {
if(WIDTH >= this.getSize().width)
WIDTH = 5;
th.sleep(200);
} catch (InterruptedException ex) {
}
repaint();
}
}
public static void main(String[] args) {
Remove d = new Remove();
d.Try();
}
}
一个关于rapaint()问题``