So I have this nice spiffy MVC-architected application in Java Swing, and now I want to add a progress bar, and I'm confused about Good Design Methods to incorporate a JProgressBar into my view. Should I:
add a DefaultBoundedRangeModel to my controller's state, and export it?
class Model { final private DefaultBoundedRangeModel progress = new DefaultBoundedRangeModel(); public void getProgressModel() { return progress; } public void setProgressCount(int i) { progress.setValue(i); } } class Controller { Model model; int progressCount; void doSomething() { model.setProgressCount(++progressCount); } } class View { void setup(Model m) { JProgressBar progressBar = /* get or create progress bar */ ; progressBar.setModel(m.getProgressModel()); } } /* dilemma: Model allows progress to be exported so technically all of the progress state could be set by someone else; should it be put into a read-only wrapper? */
use JGoodies Binding to try to connect the JProgressBar's visual state to my model's state?
class Model { private int progress; public void getProgressCount() { return progress; } public void setProgressCount(int i) { progress = i; } } class View { void setup(Model m) { ProgressBar progressBar = /* get or create progress bar */ ; CallSomeMagicMethodToConnect(m, "progressCount", progressBar, "value"); // is there something that works like the above? // how do I get it to automatically update??? } }
or something else???
edit: more specifically: could someone point me to a Good Example of realistic source for an application in Java that has a status bar that includes a progress bar, and has a decent MVC implementation of it?