Methods Summary |
---|
public void | destroy()
removeMouseListener(this);
|
public java.lang.String | getAppletInfo()
return "Title: NervousText\nAuthor: Daniel Wyszynski\nDisplays a text banner that jitters.";
|
public java.lang.String[][] | getParameterInfo()
String pinfo[][] = {
{"text", "string", "Text to display"},
};
return pinfo;
|
public void | init()
banner = getParameter("text");
if (banner == null) {
banner = "HotJava";
}
int bannerLength = banner.length();
StringBuffer bc = new StringBuffer(bannerLength);
StringBuffer attrs = new StringBuffer(bannerLength);
int wd = 0;
for (int i = 0; i < bannerLength; i++) {
char c = banner.charAt(i);
char a = 0;
if (c == '^") {
i++;
if (i < bannerLength) {
c = banner.charAt(i);
a = '^";
wd += SMALL_WD - REGULAR_WD;
} else {
break;
}
}
bc.append(c);
attrs.append(a);
wd += REGULAR_WD;
}
bannerLength = bc.length();
bannerChars = new char[bannerLength];
attributes = new char[bannerLength];
bc.getChars(0, bannerLength, bannerChars, 0);
attrs.getChars(0, bannerLength, attributes, 0);
threadSuspended = false;
resize(wd + 10, 50);
addMouseListener(this);
|
public void | mouseClicked(java.awt.event.MouseEvent e)
|
public void | mouseEntered(java.awt.event.MouseEvent e)
|
public void | mouseExited(java.awt.event.MouseEvent e)
|
public synchronized void | mousePressed(java.awt.event.MouseEvent e)
e.consume();
threadSuspended = !threadSuspended;
if (!threadSuspended)
notify();
|
public void | mouseReleased(java.awt.event.MouseEvent e)
|
public void | paint(java.awt.Graphics g)
int length = bannerChars.length;
for (int i = 0, x = 0; i < length; i++) {
int wd, ht;
if (attributes[i] == '^") {
wd = SMALL_WD;
ht = SMALL_HT;
g.setFont(smallFont);
} else {
wd = REGULAR_WD;
ht = REGULAR_HT;
g.setFont(regularFont);
}
int px = (int) (10 * Math.random() + x);
int py = (int) (10 * Math.random() + ht);
g.drawChars(bannerChars, i, 1, px, py);
x += wd;
}
|
public void | run()
Thread me = Thread.currentThread();
while (runner == me) {
try {
Thread.sleep(100);
synchronized(this) {
while (threadSuspended) {
wait();
}
}
} catch (InterruptedException e){
}
repaint();
}
|
public void | start()
runner = new Thread(this);
runner.start();
|
public synchronized void | stop()
runner = null;
if (threadSuspended) {
threadSuspended = false;
notify();
}
|