Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区 » 实战错误讨论  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:applet小程序未初始化问题? [Re:xh20021411]
xh20021411





发贴: 9
积分: 0
于 2005-05-17 17:31 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
还有一个和上面的运行结果一样的问题,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.setFontRose;
    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)Sadh-=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.printlnEnvelope;
        }
      }
    }
  
}

html:
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR="000000">
<CENTER>
<APPLET
  code  = "Myweb1.class"
  width  = "760"
  height  = "435"
  >
</APPLET>
</CENTER>
</BODY>
</HTML>
运行后还是和第一个一样,这究竟是怎么回事呀!!!!
可是运行application就可以。




话题树型展开
人气 标题 作者 字数 发贴时间
9267 applet小程序未初始化问题? xh20021411 472 2005-05-16 18:45
7815 Re:applet小程序未初始化问题? wind520sand 23 2005-05-17 00:23
7232 Re:applet小程序未初始化问题? xh20021411 6 2005-05-17 08:11
7097 Re:applet小程序未初始化问题? why 214 2005-05-17 09:14
7330 Re:applet小程序未初始化问题? xh20021411 1575 2005-05-17 17:31
7407 Re:applet小程序未初始化问题? why 681 2005-05-17 21:40

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923