Graphical User Interfaces > Example Graphical User Interface > Handling of Progress Information

Handling of Progress Information
It is possible to create a monitor for the progress of the solver. This monitor can also be used to cancel long running simulations if desired.
The progress information is made available using two different classes: SwingProgressPanel is used to display the progress in the GUI, and SwingDemoProgressContext is used to handle the communication between COMSOL Multiphysics and the areas the application that needs information about progress.
SwingDemoProgressContext extends SwingProgressContext, which is described in the reference section at the end of this chapter.
Both classes are added by copying two files instead of writing them from scratch.
1
Use the mouse to drag and drop these files to the src folder shown in the Package Explorer in Eclipse: SwingDemoProgressContext.java and SwingProgressPanel.java.
2
Open the BeamModelDemo.java file and navigate to the start method.
3
SwingProgressPanel progressPanel = new SwingProgressPanel();
mainPanel.add(progressPanel, BorderLayout.PAGE_END);
progressPanel.updateProgressLog("Starting\n");
ProgressWorker.setContext(new SwingDemoProgressContext(progressPanel));
4
5
private void solve() {
  ProgressWorker.run(new Runnable() {
    public void run() {
      model.sol("sol1").runAll();
      model.result("pg1").set("window", "window1");
      model.result("pg1").run();
    }
  });
}
6
7
Run the application by right-clicking BeamModelDemo.java in the Package Explorer and select Run as>Java Application.
8