More swing design & actions

Posted by takoi on Stack Overflow See other posts from Stack Overflow or by takoi
Published on 2010-06-13T11:00:23Z Indexed on 2010/06/13 11:02 UTC
Read the original article Hit count: 147

Filed under:
|
|

Im pretty new to gui programming so i've been reading through every post on this site about swing and design. Whats been answered over and over again is that one should have a class which handles all the action. Like this: (GUI being some JFrame)

alt text

Now, this works great for one-way actions, like OpenDialog. But the actions for buttons in DialogA and B will have to have access to all the components (there will be many) in its dialog, and the controller. This is where im stuck.

The only sane way i can see is to put it in DialogA/B but i would then need to pass the controller all the way down, through classes that dont even need it, and it'll get all spaghetti. Really dont want that.

Someone must have encountered this problem before. So where should i put this Action? Or should i just drop the whole design?

© Stack Overflow or respective owner

Related posts about java

Related posts about design-patterns