Try This 14-1 A Simple Banner Applet

Banner.java

To demonstrate repaint( ), a simple banner applet is presented. This applet scrolls a message, from right to left, across the applet’s window. Since the scrolling of the message is a repetitive task, it is performed by a separate thread, created by the applet when it is initialized. Banners are popular Web features, and this project shows how to use a Java applet to create one.

1. Create a file called Banner.java.

2. Begin creating the banner applet with the following lines:

Image

Notice that Banner extends Applet, as expected, but it also implements Runnable. This is necessary since the applet will ...

Get Java, A Beginner's Guide, 5th Edition, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.