求高手帮给这个java代码加上注释和算法描述 谢谢了!是一个圆扩散的小程序
importjava.awt.*;importjava.applet.*;publicclassCircleSextendsAppletimplementsRunnabl...
import java.awt.*;
import java.applet.*;
public class CircleS extends Applet implements Runnable
{
int W = 600, H = 600, x0 = W/2, y0 = H/2, r0 = 50, r1 = 200;
int dr = 2, r = r0, n = 10, d = 10, ms = 100;
Thread t1;
public void start( )
{
t1 = new Thread( this );
t1.start( );
}
//
public void run( )
{
while( true )
{
try{ Thread.sleep( ms ); }
catch( InterruptedException e ) { }
r = r + dr;
if( r < r0 || r > r1 ) dr = -dr;
repaint();
}
}
public void drawC( int r, Graphics g )
{
int rr;
for( int i = 0; i < n; i++ )
{
rr = r + i*d;
g.drawOval( x0-rr, y0-rr, 2*rr, 2*rr );
}
}
public void paint(Graphics g)
{
g.drawString("Hello World", 20, 20);
drawC( r, g );
}
} 展开
import java.applet.*;
public class CircleS extends Applet implements Runnable
{
int W = 600, H = 600, x0 = W/2, y0 = H/2, r0 = 50, r1 = 200;
int dr = 2, r = r0, n = 10, d = 10, ms = 100;
Thread t1;
public void start( )
{
t1 = new Thread( this );
t1.start( );
}
//
public void run( )
{
while( true )
{
try{ Thread.sleep( ms ); }
catch( InterruptedException e ) { }
r = r + dr;
if( r < r0 || r > r1 ) dr = -dr;
repaint();
}
}
public void drawC( int r, Graphics g )
{
int rr;
for( int i = 0; i < n; i++ )
{
rr = r + i*d;
g.drawOval( x0-rr, y0-rr, 2*rr, 2*rr );
}
}
public void paint(Graphics g)
{
g.drawString("Hello World", 20, 20);
drawC( r, g );
}
} 展开
1个回答
2014-06-17
展开全部
多线程画椭圆、写Hello World
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询