for(int j = 0; j < linecount; j++)
{
currentletter = 1;
String s = (String)lines.elementAt(j);
for(int k = 0; k < s.length(); k++)
{
if(soundOn && hit != null)
hit.play();
if(k == s.length() && soundOn && cr != null)
cr.play();
repaint();
int i1 = 75 + (int)(Math.random() * 100D);
try
{
Thread.sleep((i1 * speed) / 100);
}
catch(InterruptedException interruptedexception)
{
System.out.println("BB: "
+ interruptedexception.toString());
}
currentletter++;
}
currentletter = 0;
currentline++;
alreadyRun = false;
}
currentline = currentline % linecount;
try
{
Thread.sleep(pause);
}
catch(InterruptedException interruptedexception)
{
System.out.println("AA: " +
interruptedexception.toString());
}
}
}
public void paintBuffer(Graphics g)
{
if(background != null)
{
g.drawImage(background, 0, 0, this);
}
else
{
g.setColor(bgColor);
g.fillRect(0, 0, width, height);
}
g.setColor(textColor);
g.setFont(font);
FontMetrics fontmetrics = g.getFontMetrics();
for(int i = 0; i < currentline; i++)
g.drawString(
(String)lines.elementAt(currentline - i - 1),
margin, depth - (i + 1) * fontmetrics.getHeight()
);
String s = (String)lines.elementAt(currentline);
String s1 = currentletter >= s.length() ?
s : s.substring(0, currentletter);
if(fontmetrics.stringWidth(s1) > (8 * width) / 10
&& !alreadyRun && soundOn)
{
alreadyRun = true;
if(ding != null) ding.play();
}
g.drawString(s1, margin, depth);
}
public void paint(Graphics g)
{
paintBuffer(offScreen.getGraphics());
g.drawImage(offScreen, 0, 0, this);
}
public void update(Graphics g)
{
paint(g);
}
public void start()
{
if(woohoo == null)
{
woohoo = new Thread(this);
woohoo.start();
}
}
public void stop()
{
woohoo.stop();
woohoo = null;
}
public boolean mouseEnter(Event event, int i, int j)
{
if(hotlink != null) showStatus("Link to " + hotlink.toString());
if(soundactivation.equals("enter")) soundOn = true;
return true;
}
public boolean mouseExit(Event event, int i, int j)
{
if(soundactivation.equals("enter")) soundOn = false;
return true;
}
public boolean mouseDown(Event event, int i, int j)
{
try
{
getAppletContext().showDocument(hotlink, target);
}
catch(Exception e) { }
return true;
}
}