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();
  }
}

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;

You just missed one import: java.awt.event.*;
There is where ActionListener and ActionEvent are located.

Try compiling again with that, should work correctly this time. ;)

Oh my, way too many careless mistakes haha. Thanks!

Sorry for the double post, but now I'm getting this run-time error.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at HitMe.actionPerformed(HitMe.java:113)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

One more problem... My score is stuck at 0, it won't accumulate, and I don't know why. Sorry for the triple post, but I'm just getting frustrated with the whole thing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.