Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way for a Swing GUI to communicate with domain logic?

I have some domain logic implemented in a number of POJOs. I want to write a Swing user interface to allow the user to initiate and see the results of various domain actions.

What's the best pattern/framework/library for communications between the UI and the domain? This boils down into:

  • the UI being able to convert a user gesture into a domain action
  • the domain being able to send state/result information back to the UI for display purposes

I'm aware of MVC as a broad concept and have fiddled with the Observer pattern (whose Java implementation has some drawbacks if I understand correctly), but I'm wondering if there's an accepted best practise for this problem?

like image 903
Andrew Swan Avatar asked Sep 16 '08 06:09

Andrew Swan


2 Answers

Definitely MVC - something like this example which clearly splits things out. The problem with the Swing examples is that they seem to show the MVC all working within the swing stuff, which does not seem right to me

like image 115
Chris Kimpton Avatar answered Nov 03 '22 21:11

Chris Kimpton


MVC is fantastic for an individual widget, however it gets a little unruly when you have pages and forms with lots of widgets.

One thing that might be worth looking into (and I'm not endorsing it, I haven't actually used it, just implemented something very similar for myself) is the Beans Binding Framework (JSR295)

like image 35
Aidos Avatar answered Nov 03 '22 23:11

Aidos