I've got a basic javax.swing.Timer that I use to repeat itself to darken an image over and over again. This should give a fade out effect for the image however the delay on this is set to 0010 which should be so quick however it takes half a second. Then the next time I run the program it is even slower. Anyone know how to speed this timer up or is there too much information/code to process?

static javax.swing.Timer slideEffectFadeOut1 = new javax.swing.Timer(0010, new ActionListener() {
	public void actionPerformed(ActionEvent e) {
		RescaleOp rop = new RescaleOp(effect, 0, null);
		BufferedImage negative1 = rop.filter(image1, null);
		if (slideshowAction == 0) {
			resized1 = MainMenu.resize1(negative1, 670,552);
		if (slideshowAction == 1) {
			resized1 = MainMenu.resize1(negative1, screenWidth,screenHeight);
		imageIcon1 = new ImageIcon(resized1);
		effect = effect - 0.1f;
		if (effect >= 0.0f) {
		if (effect < 0.0f) {
			effect = 0.0f;

1/ initial delay is int, where TimeUnit == miliseconds not 0010, sure for preprocesor is this "value" only 10miliseconds but...

2/ usage for java.swing.TImer shloud be (and check Timer#methods f.e. timer.setDelay(int i))

private void prepareStartShedule() {
        timerRun = new javax.swing.Timer(delay / 10, startCycle());

    private Action startCycle() {
        return new AbstractAction("Start Shedule") {

            private static final long serialVersionUID = 1L;

            public void actionPerformed(ActionEvent e) {
                //some stuff with image 

3/ is better to put Image to the JLabel

4/ imagePanel1.setLayout(new BorderLayout(5,5));

5/ imagePanel1.add(someLabel, BorderLayout.CENTER);

6/ revalidate(); & repaint(); in this case,

7/ but if you will switch (only) Image into JLabel then you can call validate(); & repaint();

Hi mKorbel,

Thanks for replying to my problem. I know you mentioned that the delay is only 10miliseconds, this is because my application is lagging and will only process this timer as quick as half a second. So having it as 10miliseconds will basically queue up and do the repaint as fast as it can. As you mentioned about applying the Image straight to the JLabel. This could be an idea. Hoping that cutting down will help me to process the Timer faster. Thanks for you answer. I will try to do what you have said and will get back to you if it runs any faster. Thanks in advance

about 10msm, be sure that you have to calculated with NativeOs Latency is between 63 - 95 ms (for todays PC), under this value you can get errors from RepaintManager (if we talking about repeated outPut from some long cycle)

for blur again check Timer#methods f.e. timer.setDelay(int i)

This article has been dead for over six months. Start a new discussion instead.