import java.awt.*;
import java.applet.*;
public class SimpleBanner2 extends Applet implements Runnable
{
String msg ,message="我是滚动的字体" ;
Thread t=null;
int state;
boolean stopFlag;
 public void init()
{
setBackground(Color.cyan);
setForeground(Color.red);
}
 
  public void start()
{
    msg=getParameter("message");
if(msg==null)msg="message not found.";
msg+=" ";
t=new Thread(this);
stopFlag=false;
t.start();
}
  public void run()
{
char ch;
for (; ; )
{
try
{
repaint();
Thread.sleep(250);
ch=msg.charAt(0);
msg=msg.substring(1,msg.length());
msg+=ch;
if (stopFlag)
 break;
}
catch (InterruptedException e){}
}
}
  public void stop()
{
stopFlag=true;
t=null;
}
  public void paint (Graphics g)
{
g.drawString(msg,80,50);
}
}
我想让message 的值不是空的
也就是说我想让msg被赋予我想要输出的文字,
我是要给message赋值呢?像上面的message="我是滚动的字体" ;这是我想到的方法
但是结果还是显示message not found.这句话为什么呢?
高手们指点指点啊!拜托拜托了各位!

解决方案 »

  1.   

    implements Runnable看看啊
    你接口这个函数   就需要覆盖run()方法
    把start()的方法体写在run()中
      

  2.   

    msg直接=messgae不就行了,getParameter方法这里不能得到你要的message的value
    ---------------------
    getParameter
    public String getParameter(String name)Returns the value of the named parameter in the HTML tag. For example, if this applet is specified as 
     <applet code="Clock" width=50 height=50>
     <param name=Color value="blue">
     </applet>
     then a call to getParameter("Color") returns the value "blue". The name argument is case insensitive. 
      

  3.   

    msg=getParameter("message");
    没有这个方法,当然取到的都是NULL,所以会显示message not found
      

  4.   

    implements Runnable看看啊
    你接口这个函数   就需要覆盖run()方法
    把start()的方法体写在run()中
    -------------------------
    这里是applet的start,跟Runnable的start是两码事
      

  5.   

    这样子说我还是不怎么明白啊!
    implements Runnable看看啊???(不明白)
    那我应该怎么定义message的value值呢?
      

  6.   

    /*<applet code="SimpleBanner2.class" width="300" height="300">
    <param name="message" value="aaaa">
    </applet>*/在最后加上这句就可以了