wood burning stoves 2.0*
The moose likes Applets and the fly likes Can't create delay in Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Can Watch "Can New topic
Author

Can't create delay in Applet

Tony Higgins
Greenhorn

Joined: May 28, 2012
Posts: 2
I'm a novice when it comes to Java, and because of that this is my first real application of java that might serve some purpose. I'm trying to recreate the popular handheld game "Simon" within an applet. There is to be four colors that brighten in sequence of what the arraylist "thearray" tells them. The code is rough at this point because I've been trying to create a delay after where the first color is brightened before it returns to its original color, so the user stands a fair chance of inputting the code back in. I was trying to do this originally for the user input, but I worked around that using mousepressed and released instead of clicked. I might be using threads incorrectly, but any study I put into timers simply confused me. Here's my code for the applet and the class that creates the boxes themselves.



and the box class



I apologize for any number of java laws I just broke.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Don't ever call sleep(...) on the EDT. Use a javax.swing.Timer.

any study I put into timers simply confused me.

Go through the Tutorial, and also the section on Concurrency in Swing.


luck, db
There are no new questions, but there may be new answers.
Tony Higgins
Greenhorn

Joined: May 28, 2012
Posts: 2
Okay, so I'm working with javax.swing.Timer, and I think I understand what it's supposed to do, but I don't know how to make it happen. I have a timer created, repeats set to false, and started, but I need the actionlistener to do something, and I don't know how to continue. I need the

in side of the action listener, right? here's what I'm currently working with:


and the method of the action listener



the purpose if for the color to turn brighter, then after a delay return to its original color, and then the next color would do the same.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't create delay in Applet
 
Similar Threads
TextField Population of Mouse Events?
Drawing Problem
Help: anonymous class
i'm getting an error start:applet not intialized.
pop up menu