import java.awt.*; public class Danger extends javax.swing.JApplet implements Runnable { String text = "No text has been specified"; float hue = (float) 0.5; float saturation = (float) 0.8; float brightness = (float) 0.0; Font textFont = new Font("Dialog", Font.BOLD, 20); int textX; Thread runner; public void init() { setBackground(Color.black); String paramName = getParameter("TEXT"); if (paramName != null) text = paramName; FontMetrics fm = getFontMetrics(textFont); textX = getSize().width / 2 - fm.stringWidth(text) / 2; } public void paint(Graphics screen) { Graphics2D screen2D = (Graphics2D) screen; Color textColor = Color.getHSBColor(hue, saturation, brightness); screen2D.setColor(textColor); screen2D.setFont(textFont); screen2D.drawString(text, textX, 30); } public void update(Graphics screen) { paint(screen); } void pause(int duration) { try { Thread.sleep(duration); } catch (InterruptedException e) { } } public void start() { if (runner == null) { runner = new Thread(this); runner.start(); } } public void stop() { if (runner != null) { runner = null; } } public void run() { Thread thisThread = Thread.currentThread(); while (runner == thisThread) { pause(75); brightness += 0.05; if (brightness > 1) { brightness = (float) 0.0; pause(75); } repaint(); } } }