import java.applet.Applet; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; public class P14 extends Applet implements Runnable { private String bannerText; private int xCoordinate; private Thread thread; public void init() { bannerText = "Goofy ahh banner!"; xCoordinate = getWidth(); setBackground(Color.WHITE); setForeground(Color.BLACK); setFont(new Font("Arial", Font.BOLD, 20)); } public void start() { if (thread == null) { thread = new Thread(this); thread.start(); } } public void run() { while (true) { xCoordinate -= 5; if (xCoordinate + 200 < 0) { xCoordinate = getWidth(); } try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } repaint(); } } public void paint(Graphics g) { g.clearRect(0, 0, getWidth(), getHeight()); g.drawString(bannerText, xCoordinate, 50); } }