views:

49

answers:

3

I am planning to write a Java applet for Tower of Hanoi similar to link( http://www.mazeworks.com/hanoi/index.htm ) Can you suggest how should I start and proceed.

And, btw, does it require multi threading?

And also, major part of my doubt is

  • to make a disc being clickable and being able to drag and drop the disc on a tower.

  • detect a tower (if a disc is being dragged using mouse)

A: 

To answer the multi-threaded question, all GUI applications are multi-threaded (or have to fake it - but in the case of standard Java GUI stuff, they're all multi-threaded). That's because they have to deal with events, including repaint requests and such as well as user input. The algorithm itself shouldn't require multiple threads, and you shouldn't have to do a lot with threads (it'll primarily be a case of implementing the proper event handlers), but you're definitely going to have multiple threads for an applet.

Jonathan M Davis
Actually all events are single threaded and run in the event-dispatching thread. Do not execute updates to the windows from multiple threads, instead use invokeLater() and invokeAndWait(). I am dinging you because you are giving bad advice.
Romain Hippeau
A: 

I would start with this http://www.rstack.com/hanoi/hanoi_src.html or http://stud1.tuwien.ac.at/~e9125168/javaa/jtower.html. As far as threading see my comment on Jonathan M Davis's answer.

Romain Hippeau
A: 

You can do it with javafx it is easier than core java. Here is an example

Enrique