denni2727 0 Newbie Poster

I'm developing an application which uses a Timer so that the JButtons that the application has, blink each half a second, And the problem is that it works properly until I make some JButtons fire events.

When this happens the timer speeds up, but its delay is the same. I have tried doing a lot of things but i can't find the reason of this problem. I have taken the time before and after the method execute and the result is the delay of the timer when the timer runs normal and when it runs fast, So I start thinking that the problem is in the vm.

I don't know what to do so I would like you guys to help me if you could, or send me how to make a JButton in a group of buttons blink when it gets the focus in a different way.

Any help would be appreciated. Here a write some of my application's code:

public void actionPerformed(ActionEvent arg0) {
		// This is the action listener of the timer	
                       
			if(getImage() != null) //Here i check if the button is a Image button or a text Button
			{
				if(isForeground)
				{
					getActual().setIcon(getBlank());//actual is a JButton and Blank is an icon with the background color.
				}else
				{
					getActual().setIcon(getImage());	 
				}
			}
			else{
				if(isForeground)
				{
					getActual().setForeground(getBg());
					
				}else
				{
					getActual().setForeground(getFg());
					
				}
			}
			isForeground = !isForeground;
			
                        //i used this to measure the time when i was testing it.
                       //newTime = System.currentTimeMillis();
			//System.out.println(newTime - oldTime);
			//oldTime = System.currentTimeMillis();
	}