How do I wrap propertyChanged code into an event dispatch thread?
/*
* EventRunnableHandler.java
*
* Created on March 14, 2007, 3:36 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.ppowell.tools.ObjectTools.SwingTools;
import java.util.EventObject;
/**
* Wrapper for Runnable interface that will allow for {@link java.util.EventObject}
* @author Phil Powell
* @version JDK 1.6.0
*/
publicclass EventRunnableHandlerimplements Runnable{
/**
* {@link java.util.EventObject}
*/
private EventObject evt;
/**
* Creates a new instance of EventRunnableHandler
* @param evt {@link java.util.EventObject}
*/
public EventRunnableHandler(EventObject evt){
this.evt = evt;
}
/** Perform run */
publicvoid run(){}
}
/**
* Invoked when task's progress property changes.
*/
publicvoid propertyChange(PropertyChangeEvent evt){
SwingUtilities.invokeLater(new EventRunnableHandler(evt){
publicvoid run(){
if (evt.getPropertyName() =="progress"){
int progress = (Integer)evt.getNewValue();
progressBar.setValue(progress);
}
}
});
}
This code fails to compile producing the error message:
local variable evt is accessed from within innerclass; needs to be declaredfinal
Bluntly put, how do I fix this?
Thanx
Phil

