How to use Progress Indicator propertly

My plugin project  has dialog which implements DialogWrapper, when click "OK", I did some work such as making connection to server, I tried to pop up the progress monitor dialog(just like
Eclipse) to show the progress, here is my code, however, I did not see any progress dialog pop up, what is the right way to apply progress indicator?

Okbutton..addActionListener(new ActionListener()
{
public void actionPerformed(final ActionEvent e)
{
try
{
// Comparing
ProgressManager.getInstance().runProcessWithProgressSynchronously
(
new Runnable()
{
public void run()
{
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
try
{
// Now comparing
indicator.setText(
"Testing Connection");
indicator.setText2("starting");
indicator.setFraction(0.5);
indicator.setIndeterminate(true);
//Here are the code to make connection to server ..................
..............................
if (indicator.isCanceled())
{
throw new ProcessCanceledException();
}
}catch(Exception e){/////}
}//run
}//Runnable
"Doing connection..", true, myproject);
}catch(Exception e){/////}
} }

1 comment
Comment actions Permalink

Your code looks correct to me. The indicator will not be shown if the process under progress completes in less than a certain amount of time (0.5 seconds or so).

0

Please sign in to leave a comment.