A summary of the errors I have received can be found here - [IMG]http://i46.tinypic.com/2cdcvat.jpg[/IMG]
import javax.swing.event.*;
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import java.applet.AudioClip;
public class Whackan extends JFrame implements ActionListener
{
JButton[][] spots = new JButton [ 5][ 5];
JLabel score = new JLabel();
int maxDelay = 1000;
double hits = 0;
double turns = 0;
double maxTurn = 0;
ImageIcon alive = new ImageIcon("alive.GIF");
T runner = null;
URL sci = null, dr = null;
AudioClip scientific = null, door = null;
public Whackan()
{
super("Whack-an Evil Genius");
setSize(350, 475);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try
{
sci = this.getClass().getResource("sci.wav");
dr = this.getClass().getResource("door.wav");
scientific = JApplet.newAudioClip(sci);
door = JApplet.newAudioClip(dr);
}
catch(Exception e){}
maxTurn = Double.parseDouble(JOptionPane.showInputDialog("How many chances do you\n" +
"want to whack an evil genius?"));
Container cont = getContentPane();
cont.setLayout(new FlowLayout());
JLabel title = new JLabel(new ImageIcon("title.PNG"));
cont.add(title);
for (int i = 0; i < spots.length; i++)
{
for (int j = 0; j < spots[ 0].length; j++)
{
spots[ i][ j] = new JButton(alive);
cont.add(spots[ i][ j]);
spots[ i][ j].setEnabled(false);
spots[ i][ j].addActionListener(this);
}
}
score.setText("Turn " + turns + "/" + maxTurn + ". Current Score: " + ((int)
((hits/maxTurn)*100)));
cont.add(score);
setContentPane(cont);
runner = new T();
runner.start();
}
public class T extends Thread
{
public void run()
{
while(true)
{
if(turns >= maxTurn)
{
JOptionPane.showMessageDialog(null, "The game is over.\n\n" + "You hit" + hits + " evil geniuses in " + turns + "turns.\n" + "Your score is " +((int)(((hits*10000/turns)))), "Game Over", JOptionPane.INFORMATION_MESSAGE); break;
}
turns++;
int timeDelay = (int)(Math.random()*1500);
try
{
Thread.sleep(timeDelay);
}
catch(Exception e)
{}
int genius = (int)(Math.random()*5);
int genius2 = (int)(Math.random()*5);
spots[ genius][ genius].setEnabled(true);
try
{
door.play();
Thread.sleep(maxDelay);
}
catch(Exception e)
{}
spots[ genius][ genius2].setEnabled(false);
score.setText("Turn " + turns + "/" + maxTurn + ". Current Score: " + ((int)(((hits*10000)/maxTurn))));
}
}
}
public void actionPerformed(ActionEvent e)
{
maxDelay-=100;
scientific.play();
hits++;
try
{
runner.sleep(500);
Thread.sleep(500);
}
catch(Exception ex)
{}
}
public static void main(String[] args)
{
new Whackan();
}
}