Google

IBM

Nervous Text applet

This example is an applet which displays some moving text in a window; this applet follows the algorithm used in one of the earliest Java applets, 'NervousText'.

Here's the source, as a plain ASCII file.

This one is a bit more sophisticated than the 'Hello World' applet: the text jiggles, and you can start or stop the movement by clicking on the applet window.

The applet is compiled using the same steps as for the 'Hello World' applet. Unlike 'Hello World', however, this applet takes as a parameter the text to be displayed; to have the applet displayed in World Wide Web page, you need to

  1. place the class file in the same directory as the page in which is is to appear
  2. refer to it, wherever you want it to appear on the page, with the <applet> tag:
    
      <applet code="NervousTexxt.class" width=300 height=50>
    
      <param name=text value="NetRexx applet">
    
      </applet>
    
    

    which sets the maximum size for the window in which the applet will appear, and the text that will appear.

You can then view the page with any Java-enabled browser, or with the 'applet viewer' that comes with the Java Development Kit. If you are using such program, you should see the applet below here.

For more details on running applets, see the Hello World applet page.


[ IBM | Help | Legal | Privacy ]