import java.awt.*;
class window extends JWindow{
int length=0;
public window(){
setBounds(200,200,600,400);
setVisible(true);
}
public void paint(Graphics g){
g.setFont(new Font(null,Font.BOLD,20));
g.drawRect(100,100,350,50);
setForeground(Color.black);
try{
Thread.sleep(200);
if(length<=350){
g.setColor(Color.red);
float m=((float)length/350)*100;
String ch="%";
ch=String.valueOf(m).concat(ch);
g.drawString(ch,95,95);
g.fillRect(100,100,length,50);
length+=2;
//super.paint(g);
repaint();
}
}catch(Exception e){}
}
}
public class windows{
public static void main(String[] args){
new window();
}
}
请高手指教如何使提示信息百分数每次重画前把以前的清掉.谢谢!!