Sample Code Sample Code: Set Center Status Info Pane


boolean showProgress = true;
...
final JProgressBar progressBar = new JProgressBar(0, 100);
progressBar.setValue(0);
progressBar.setStringPainted(true);
Object[] args = new Object[1];
args[0] = new Integer(progressBar.getValue()); progressBar.setString(MessageFormat.format("{0}%", args)); progressBar.setVisible(showProgress); myTool.fireConsoleAction(new VConsoleEvent( myTool, VconsoleActions.UPDATEPROGRESS, showProgress ? progressBar : null)); ... // As the operation proceeds (presumably in a seperate thread), // update the progress bar. // We assume "count" and "total" are integer variables // that represent the cumulative status thus far and the total // expected. if (count >= total) progressBar.setValue(100); else progressBar.setValue((count * 100)/total); Object[] args1 = new Object[1];
args1[0] = new Integer(progressBar.getValue()); progressBar.setString(MessageFormat.format("{0}%", args1)); ... // Later when the operation is complete, we want to disable // the progress meter and remove it from the center pane. myTool.fireConsoleAction(new VConsoleEvent( myTool, VConsoleActions.UPDATEPROGRESS, null));