下面是一个简单的小程序代码,问题出在 for 循环完成后。
小程序屏幕上不显示任何内容。
我猜屏幕在循环完成后被清除。
我无法修复它,我想知道如何防止屏幕清除,以便我的输出在屏幕上。
public class ColorArcs extends Applet
{
int width=50;
int length=50;
int topx=200-25,topy=200-25;
public void paint(Graphics g)
{
for(;length<250;)
{
g.drawArc(200-length/2,200-width/2,length,width,0,180);
length+=2;
width++;
if(length>=50&&length<=75)
setForeground(Color.cyan);
else
if(length>=75&&length<=100)
setForeground(Color.yellow);
else
if(length>=100&&length<=125)
setForeground(Color.green);
else
setForeground(Color.red);
try
{
Thread.sleep(80);
}
catch(InterruptedException ie){}
}
}
}
慕虎7371278
德玛西亚99
ibeautiful
相关分类