What would be the best way to add an OnLoad (?) to simulate clicking
the
buton when launching the application.
Refactor your code to cleanly separate any model-layer logic from view-
layer or controller-layer code.
The anonymous ActionListener subclass you have above is controller-
layer code; its actionPerformed() method should just invoke the
equivalent "behavioral" method at the model layer. The code above
looks like it's doing the right thing in this case. If you have other
such methods that have more code in them, trim it out and put it in
its right place...
The end result of a well-factored MVC design is that where you
currently want to force "a button to run during startup of the
application" you can *just* use the model-layer code,
queue.connect(). Any view-layer objects (interface elements) that
care about the queue's connection state etc. should be updated
automatically, because their updates should be dependent on changes
posted by model-layer state, not by direct fiddling from the model-
layer code.
At least, that's how I'd do this kind of thing in Cocoa, which makes
proper MVC design very easy. (Especially with the combination of
Interface Builder, bindings, and key-value observing to handle
propagating state automatically between layers.) It doesn't seem like
it should be too tough to do in Swing though; you'd just tend to do it
by writing glue code like the above anonymous ActionListener subclass.
-- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden