把这个APPLET放到JFRAME里的就可以了

解决方案 »

  1.   

    我想学习如何把APPLET改成应用程序
      

  2.   

    public class SimpleBanner extends JFrame implements Runnable {//changed by newman
      String msg = " A Simple Moving Banner.";
      Thread t = null;
      int state;
      boolean stopFlag;
    public void init() {
        setBackground(Color.cyan);
        setForeground(Color.red);
      }
    public void start() {
        t = new Thread(this);
        stopFlag = false;
        t.start();
      }   public SimpleBanner  (){//changed by newman
          init();
       }    public static void main(String args[]) {//changed by newman
            SimpleBanner  t=new SimpleBanner ();
            t.start();
            t.pack();
            t.show();
        }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, 50, 30);
      }
    }