Skip to main content

Using Timer - button won't respond

1 reply [Last post]
Joined: 2006-10-03


I could really use some help. I created a screen saver and I have a JButton that controls the stop/start of the screen saver. However, when the screen saver is moving fast (I control that with a JSlider), the stop button does not respond. I have to click it fast, repeatedly, and eventually it responds. I put a System.out.println to see if I was even getting in to the action listener of my button when it was not responding, and I was not.

Any ideas?



Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-12-18

If your screensaver rendering is done in the event thread, it may clog. That would explain why your events seem to disappear.

Keep in mind that Timers have a 16ms granularity in Windows. They may coalesce their events to fit this time frame.

Depending on your processing power, it may also be a simple case of CPU overload. Events from the native system may get lost in the process. You could try lowering the priority of your rendering thread to give some breathing space.

Could you otherwise give a code snippet of your event handling and rendering code?