Hi,
I am developing a Web Client with Swing and have the following problem. I am polling some images from a gateway. I use a swing worker to fetch the images and a swing timer to poll. After choosing disconnect the timer has to stop and the display panel where i show the images has to be resetted.
ActionListener taskPerformer = new ActionListener(){
public void actionPerformed(ActionEvent e) {
LiveJPEGTask task = new LiveJPEGTask(gw, cam, display);
task.execute();
}
};
javax.swing.Timer liveTimer = new javax.swing.Timer(300, taskPerformer);
liveTimer.start();
The problem is that after i perform stop and reset everyting in display panel the swing worker calls one more image and sets again this image at the display panel. So is it possible after i call timer.stop() to stop the executing of the swing worker?
public void disconnectFromServer(final Gateway gateway)
{
Set<DisplayPanel> dpanels = timers.keySet();
for (DisplayPanel dp: dpanels)
{
if(dp.getGateway()!= null)
{
if(dp.getGateway().equals(gateway))
{
Timer t = timers.get(dp);
if(t.isRunning())
{
t.stop();
t = null;
dp.setCameraName("[no camera]");
dp.setTimestampString("");
dp.setImage(null, null);
}
}
}
}