Re: Timer as an inner class
- From: "Allan M. Bruce" <allanmb@xxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 30 Mar 2006 14:56:37 +0100
"raam" <muthuramantripura@xxxxxxxxx> wrote in message
news:1143725960.805662.128380@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,
I am trying to use a timer to make a label blink in a frame.I am adding
a class inside the frame for this purpose.But whe i compile it says '
<identifier > expected at the line
timer.schedule( <-here task,period);
I hve given the code below.Can anyone please help.
Raam
Code:
class Tmier {
int delay = 5000; // delay for 5 sec.
int period = 1000; // repeat every sec.
java.util.Timer timer = new java.util.Timer();
class task extends TimerTask{
public void run() {
if(LQ.getForeground().equals(Color.RED))
LQ.setForeground(LQ.getBackground());
else
LQ.setForeground(Color.RED);
repaint();
}
}
timer.schedule(task,period);
}//Inner class Timer
I suggest using something like this instead:
javax.swing.Timer myTimer = new javax.swing.Timer(period, new
ActionListener()
{
public void actionPerformed(ActionEvent xiEvent)
{
// do your things in here
}
});
myTimer.setInitialDelay(delay);
myTimer.start();
HTH
Allan
.
- Follow-Ups:
- Re: Timer as an inner class
- From: raam
- Re: Timer as an inner class
- References:
- Timer as an inner class
- From: raam
- Timer as an inner class
- Prev by Date: Re: help needed - decompiling
- Next by Date: Re: Timer as an inner class
- Previous by thread: Timer as an inner class
- Next by thread: Re: Timer as an inner class
- Index(es):
Relevant Pages
|