0

In my school project (simple Swing application) I have a class that does some computational stuff (trains neural network) and this computation runs in iterations. I would like to actualize some GUI components (JProgressBar) and show to the user what iteration is actually processed (e.g. 100/10000).

I would like to ask how to accomplish it with respect to application design. I don't want to mix computation code with code for refreshing GUI components. Is it a proper situation to use Observer design pattern? If so, I can set my computation class as an observable object and register observer - class that will actualize JProgressBar.

Is it ok or is there some better way how to achieve it?

user2148736
  • 1,283
  • 4
  • 24
  • 39

1 Answers1

2

Depending on how much time your computation takes, you should also consider SwingWorker. Also having observer or some kind of handler which will update gui is good idea.

Kieper
  • 315
  • 2
  • 8