Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Click won't work!

Status
Not open for further replies.

jimbo1999

Programmer
Mar 11, 2003
11
0
0
GB
I've created a simple tic tac toe game (just to get the hang of java applets) and used the MouseListener system of detecting mouse clicks. When the mouse is clicked on the applet the code checks where on the board the click was and places a cross in that square.

When I uploaded the html and class file to the web it seemed to play fine when I tested it (using the same computer it was written on). I tried to play it at a friends house but it will not work on his PC. I've also tried on several other computers and it doesn't work.

The problem is that it is not responding to any mouse clicks. The board draws correctly, but nothing else happens if you try and click.

Any help would be appreciated.

James Francis.


PS The game is at I haven't yet figured out images so the noughts and
crosses are represented by yellow and blue squares -
that's if it works!
 
Hi,

If you click (on the browser) on View-->Java Console (IE 5/6) you will see the problem, which is :

Code:
Exception occurred during event dispatching:
java.lang.NoSuchMethodError: java/util/Random: method nextInt(I)I not found
	at NandC.mouseReleased
	at java/awt/Component.processMouseEvent
	at java/awt/Component.processEvent
	at java/awt/Container.processEvent
	at java/awt/Component.dispatchEventImpl
	at java/awt/Container.dispatchEventImpl
	at java/awt/Component.dispatchEvent
	at java/awt/EventDispatchThread.run

Now if you look at the API docs on :

You will see that that method has been available since Java version 1.2. Now my JVM (type "v" in the browser's Java console) is Microsoft version, and I have a feeling they never conformed to Sun's 1.2 spec - hence fore anyone using a Microsoft JVM, you'll have problems.

The easiest way around this is to use another method to replace Random.nextInt(int n) - or to enforce a download of the Java JRE and JVM.

Hope this clears things up for you ...

Ben

PS, your link to the source code is broken.
 
Yea thanks. I had no idea it was the random number generator causing problems. Any ideas how to get round it (such as another method)?

Or how to enforce a JRE download? Sorry I'm quite new to this and I hope this newby posting doesn't get on everyone's nerves.

James.

PS Thanks bout the broken link. Will fix.
 
In place of the nextInt(int n) method, I would either create an new Random() object, or use a method that was available since 1.1 - maybe nextInt() ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top