42 import java.awt.Graphics;
44 import java.applet.Applet;
45 import java.awt.event.MouseEvent;
46 import java.awt.event.MouseListener;
56 @SuppressWarnings(
"serial")
64 static final int REGULAR_WD = 15;
65 static final int REGULAR_HT = 36;
66 static final int SMALL_WD = 12;
67 static final int SMALL_HT = 24;
68 Font regularFont =
new Font(
"Serif", Font.BOLD, REGULAR_HT);
69 Font smallFont =
new Font(
"Serif", Font.BOLD, SMALL_HT);
73 banner = getParameter(
"text");
78 int bannerLength = banner.length();
79 StringBuilder bc =
new StringBuilder(bannerLength);
80 StringBuilder attrs =
new StringBuilder(bannerLength);
82 for (
int i = 0; i < bannerLength; i++) {
83 char c = banner.charAt(i);
87 if (i < bannerLength) {
90 wd += SMALL_WD - REGULAR_WD;
100 bannerLength = bc.length();
101 bannerChars =
new char[bannerLength];
102 attributes =
new char[bannerLength];
103 bc.getChars(0, bannerLength, bannerChars, 0);
104 attrs.getChars(0, bannerLength, attributes, 0);
106 threadSuspended =
false;
108 addMouseListener(
this);
113 removeMouseListener(
this);
118 runner =
new Thread(
this);
123 public synchronized void stop() {
125 if (threadSuspended) {
126 threadSuspended =
false;
133 Thread me = Thread.currentThread();
137 synchronized (
this) {
138 while (threadSuspended) {
142 }
catch (InterruptedException e) {
150 int length = bannerChars.length;
151 for (
int i = 0, x = 0; i < length; i++) {
153 if (attributes[i] ==
'^') {
156 g.setFont(smallFont);
160 g.setFont(regularFont);
162 int px = (int) (10 * Math.random() + x);
163 int py = (int) (10 * Math.random() + ht);
164 g.drawChars(bannerChars, i, 1, px, py);
172 threadSuspended = !threadSuspended;
173 if (!threadSuspended) {
196 return "Title: NervousText\nAuthor: Daniel Wyszynski\n"
197 +
"Displays a text banner that jitters.";
203 {
"text",
"string",
"Text to display" }, };