xh20021411
发贴: 9
积分: 0
|
于 2005-05-17 17:31
还有一个和上面的运行结果一样的问题,applet程序如下: import java.awt.*; import java.applet.*;
class Myweb1 extends Applet implements Runnable { Thread mythread=null; int x,y,x1,y1; int j,h; int red,green,blue; Font f=new Font("TimesRoman",Font.ITALIC,45); public void init() { x=0; y=25; x1=0; y1=50; j=0; h=760; } public void start() { if(mythread==null) mythread=new Thread(this); mythread.start(); } public void stop() { if(mythread!=null) mythread.stop(); }
public void paint(Graphics g) { g.setFont; g.setColor(Color.black); g.fillRect(0,50,760,435); g.setColor(new Color((int)(Math.random()*255),(int)(Math.random()*255),(int)(Math.random()*255))); x=(j<760)?(j+=1)h-=1); if(h==0) { h=760;j=0; } g.drawString("欢迎光临Mark网页",x,y); for(int loop=0;loop<100;loop++) { red=(int)Math.random()*255; green=(int)Math.random()*255; blue=(int)Math.random()*255; x1=(int)Math.random()*760; y1=(int)Math.random()*435; g.setColor(new Color(red,green,blue)); if((red<200)&&(green<200)&&(blue<200)) g.drawString("*",x1,y1); } } public void run() { while(true) { repaint(); try { Thread.sleep(50); } catch(Exception e) { System.out.println; } } } }
html: <HTML> <HEAD> </HEAD> <BODY BGCOLOR="000000"> <CENTER> <APPLET code = "Myweb1.class" width = "760" height = "435" > </APPLET> </CENTER> </BODY> </HTML> 运行后还是和第一个一样,这究竟是怎么回事呀!!!! 可是运行application就可以。
|