aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Limiting User Input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Limiting User Input" Watch "Limiting User Input" New topic
Author

Limiting User Input

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I am writing a connect four game for an artificial intelligence course. The first phase of the project is to write a user interface. Since I'm sometimes a little bit of an over-achiever, I decided to create a GUI and do some fancy animations and such. I've written the program and it's good enough to turn in. Since there is quite a bit of code, I decided not to post it; instead, anyone that offers to help can download the source as a jar file from my school webspace.

I still have some problems that may come back to bite me when I go and develop the AI portion so the user can play against the computer. At the moment, it's just made to allower to human players to play against each other. The problem is that if the user clicks on the game board quickly several times in a row, the animation for the falling pieces is all screwed up.

I'm trying to use the Model-View-Controller pattern for my connect four board. In particular, I have three classes ConnectFourBoard (the model), ConnectFourPanel (the view), and ConnectFourController (the controller). Another difficulty is that I'm creating a separate Thread for the animation so that the GUI still responds to some user input that should still be allowed (such as navigating the menu). While this isn't crucial, I thought it would be a good idea.

I'm having a difficult time finding an elegant way to ignore mouse clicks on the ConnectFourPanel while the animation is going. This will be especially crucial because when I start implementing the AI routines, I don't want the user to be able to make a move while the computer is "thinking" about which move to make. Does anyone have any suggestions of how I can implement this in my current design framework?

Any suggestions will be greatly appreciated.

Thanks,

Layne

p.s. Also, if this question would be more appropriate in a different forum, please let me know. There are several choices in my mind, but this GUI forum makes the most sense to me.


Java API Documentation
The Java Tutorial
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
Do some searching on Glass Plane. It's not actually a class, but searching on that should find you some solutions.

One other thing. I hate to mention this, and you may not want to look, but Connect 4 has been solved. Of course that doesn't stop you from building an AI for it.

Have fun.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Steven Bell:
I hate to mention this, and you may not want to look, but Connect 4 has been solved. Of course that doesn't stop you from building an AI for it.

Have fun.


I'm sure it has. It's not that difficult of a game. But as I mentiond I'm doing it for a class project. Besides, it's an interesting educational experience.

I'll look into your suggestions about Glass Pane, too. Thanks.

Layne
 
 
subject: Limiting User Input