• Post Reply Bookmark Topic Watch Topic
  • New Topic

progress dialog staying open  RSS feed

 
ian brown
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a problem that my progressDialog bar sometimes, very rarely mind you, stays open even though it should be finished if I run my GUI application in UNIX, it does not appear to happen in Windows. Has anyone else experienced this or have any idea from the code pasted below why it might be happening.
thanks in advance,
ian
/**
* ProgressDialogController
*
*
*/
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;

public class ProgressDialogController extends AbstractDialogController
implements ActionListener {
private ProgressDialogView view;
private ProgressUpdater progressUpdater = new ProgressUpdater();
private IProgressDialogCallBack ipdcbListener = null;
private boolean bCancelButtonNeeded = true;
public ProgressDialogController( RequestHandler requestHandler, boolean bCancelButtonNeeded ) {
this.ipdcbListener = requestHandler;
this.bCancelButtonNeeded = bCancelButtonNeeded;
}
protected void init() {
view = (ProgressDialogView)getView();
view.messageText.setText( "" );


if ( bCancelButtonNeeded ) {
view.addCancelButton();
view.cancelButton.addActionListener(this);
}
Timer timer = new Timer(500, progressUpdater);
timer.setRepeats(true);
timer.start();
}
protected void viewClosing() {
ipdcbListener.respondToCancelEvent();
}
protected void stop() {
// dialog is closing so can't retrieve
// any updates anymore
ipdcbListener = null;
if ( bCancelButtonNeeded ) {
view.cancelButton.removeActionListener(this);
}
view = null;
progressUpdater = null;
}
public void actionPerformed(ActionEvent event) {
// it may take some time to finish
// current job, so we desable cancel button
// but wait till dialog will be shut down
// by its owner
if ( bCancelButtonNeeded ) {
view.cancelButton.setEnabled( false );
}
// notify owner about cancel request
ipdcbListener.respondToCancelEvent();
}
public void updateMessageOnProgressDialog( String strMessage ) {
if ( view!=null ) {
if ( view.messageText != null ) {
view.messageText.setText( strMessage );
}
}
}
private class ProgressUpdater implements ActionListener {
private int progress;
public void actionPerformed (ActionEvent e) {
if (view != null) {

progress = progress + 20;
if (progress > 100) progress = 0;
view.progressBar.setValue(progress);
}
}
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!