> Hi all--
>
[quoted text clipped - 32 lines]
> --- when trialNum trials have completed, the experiment thread
> exits.
I recommend you print the above, put it in an envelope addressed to
yourself marked "do not open until 2013". If it makes no sense to you
then, you'll understand why people ask for SSCCEs.
> Right now, the second frame hangs upon display ( while the controller
> is running ). Note that if I ditch the initial frame and fire up the
> controller directly, no problems. Why is this?
That's easy. Running non-GUI code on the EDT is the number one cause of
GUI hang/freeze/lockups IME.
> Secondly, is this a really messed up design?
To me, using sleep is a sign of messed up design. That's because I only
ever use it to simulate the effect of slow databases on my GUI code so
that I can smoke out timing issues. This doesn't mean there aren't good
uses of sleep, but waiting for events probably isn't one of them.
> - I was trying to separate out business from display logic, and it
> does seem to be cleaner than munging both controller/display
> together.
I think most people would say that is good practise.
> - I decided for the controller to dominate the display, rather than
> vice versa. Perhaps this is thinking too procedurally, but I was
> thinking that the display could totally change, and the controller
> could stay largely the same. Fundamentally, I thought this modelled
> the natural dependency of the results display on the results logic.
?
> - Is there a way for me to run the experiments procedurally in a big
> for loop that waits for input,
Yes.
> without causing headaches?
No.
> The
> alternative I can think of is to have the controller be passive, and
> react to events. That means instead of a for loop, I need to use
> promote some of those iterator variables into class members, and say,
> each time a user input is fired off
Your design sounds overly complicated to me. That's probably because I
haven't understood your description.
I'd have a JFrame with TextFields, JSpinners, etc for user input and a
big "Go" button that users would click every time they've entered a new
set of "experimental input". An ActionListener on the "Go" button would
open a modal JDialog with a JProgressBar and some component(s) that
eventually displays the results. The "Go" button's ActionListener would
also use SwingWorker to start a worker thread that "processes the
experimental input". The done() method of the SwingWorker would update
the "results" widgets. SwingWorker has provision for progress
notifications that can be used to update a JProgressBar.
If necessary, I'd use Listeners of some sort to further organise the
code according to MVC pattern. I suspect this wouldn't be needed.
> Any good reading you might suggest as well related to this topic?
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html
http://en.wikipedia.org/wiki/Model-view-controller
http://java.sun.com/blueprints/patterns/MVC.html
I'd use Google to search this newsgroup for book recommendations
concerning OO design patterns.
zikester - 25 Mar 2008 00:40 GMT
On Mar 23, 4:05 am, RedGrittyBrick <RedGrittyBr...@SpamWeary.foo>
wrote:
> > Hi all--
>
[quoted text clipped - 102 lines]
> I'd use Google to search this newsgroup for book recommendations
> concerning OO design patterns.
Thanks---pretty much confirmed my fears.