File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes TicTacToe in Java Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "TicTacToe in Java Applet" Watch "TicTacToe in Java Applet" New topic

TicTacToe in Java Applet

Yong Park

Joined: Apr 13, 2004
Posts: 2
basically this is my end of the year project.
I do not have much knowledge in Java but I do have Perl and C++ programming background. I jumped right into this project started to test few things out and I am lost big time. The error message reads "illegal start of expression" and points to "public void paint". What am I doing wrong?
[ edited to format code a bit and to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ April 14, 2004: Message edited by: Dirk Schreckmann ]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Non Dairy,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Yong Park

Joined: Apr 13, 2004
Posts: 2
I just changed it. I guess I should've looked at that "naming policy"! After I saw the forum guidelines and rules and regulations, I didn't feel the need to look at it.
hopefully someone can come up with an answer to my question.. I am digging through my books and constantly refreshing this post!! Also any suggestions on how to go about doing this applet will be appreciated(algorithms and useful native java packages).
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Welcome to object-oriented programming in Java.
Without spending the time to learn to program in Java, you're likely to have a hard time programming in Java.
Note that class is not a set of instructions that get sequentially executed when loaded into memory.
Follows is a modified version of your applet that will compile, run and do something. But this isn't really an example of something well-designed. Perhaps it'll give you an idea for getting started.

With an applet, getting user input through the console probably isn't a good idea, especially as many applet users don't have their console enabled and displayed. Something like a text field would be more appropriate.
Also, as in this ugly example, putting the program control logic in the paint method isn't a good idea. The paint method is for displaying something, not for controlling the flow of a program.
Here is a list of free on-line tutorials and books that I have found useful for learning about programming in Java:
  • Sun's Java Tutorial
  • Introduction to Computer Science using Java by Bradley Kjell
  • Introduction to Programming Using Java by David J. Eck
  • Dick Baldwin's Java Programming Tutorials
  • Interactive Programming In Java by Lynn Andrea Stein
  • Bruce Eckel's Thinking In Java
  • JavaRanch's own Campfire Stories
  • Allen B. Downey's How To Think Like A Computer Scientist
  • Good luck, and don't hesitate to post more questions around here.
    I agree. Here's the link:
    subject: TicTacToe in Java Applet
    It's not a secret anymore!