I Have 3 sets of JMenuItem
on a View class of the MVC framework. I want to refer to them in the controll class EventController
. Can someone show me thi
Let your model export instances of Action that can be added to menus and buttons as needed. Because database access is inherently asynchronous, let each such action use a worker thread to query the database in the background while updating the table mode on the EDT. See also A Swing Architecture Overview concerning the relationship between Swing components and models.
Addendum: Can you show me a code sample?
FileMenu is a very basic example of using Action
to encapsulate functionality.
The example cited here uses Action
more extensively in a JToolBar
.
JHotDraw, cited here, is a very complex example that changes the available Action
instances based on context, as discussed here.
This example offers a general examination of MVC in Swing.