javax.swing.timer

How do you create a javax.swing.Timer that fires immediately, then every t milliseconds?

Right now, I have code that looks something like this: Timer timer = new javax.swing.Timer(5000, myActionEvent); According to what I'm seeing (and the Javadocs for the Timer class), the timer will wait 5000 milliseconds (5 seconds), fire the action event, wait 5000 milliseconds, fire again, and so on. However, the behavior that I'm tr...

Javax.swing timer repeats fine, but ActionListener doesn't do anything.

I am trying to flash the background colour in a textfield. My timer setup is as follows: Flash flash = new Flash(); //set up timer tmr = new javax.swing.Timer(1000, new Flash()); tmr.addActionListener(flash); tmr.setInitialDelay(0); tmr.setRepeats(true); tmr.start(); My actionListener is as...

JFrame that has multiple layers

Hello, I have a window that has two layers: a static background and a foreground that contains moving objects. My idea is to draw the background just once (because it's not going to change), so I make the changing panel transparent and add it on top of the static background. Here is the code for this: public static void main(String[] a...