• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

actions handling

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi people!
I would like to consult with you.
On client side I have FileMenu which is responsible for local and remote connection. For this menu I use FileListener class.
For book and search button I apply Command pattern.
Question: Is it OK to have such actions scheme for application or it is better to have general Controller for handling file menu actions, button actions, table selected action and so on.
Thank You in advance,
Andrew
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the simplicity and ease of reading, a controller is better, not to say that your way would lose any points.
And this assignment is on the simplicity side.
Mark
 
Andrew Douglas
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark!
In my GUI I tried different ways to handle actions:
Inner classes, Public classes, Command pattern with Mediator, Controller. In any case everything works fine. But I can't come to a decision which way is better. Not only for this assignment. For example if we have File menu, Edit menu, View menu and so on. I think for each menu it is better to have separate Handler or ...
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at some of my code here, and tell me if this will help.
This code is in the GUI class, they are separate methods to hook the Controller into the GUI class, and get ActionListeners etc.

and



OK Now here is the code in the controller that will attach a controller method to an Object on the GUI as the ActionListener.

Now the above code in the GUI and controller almost completely match, I just left a couple out of the GUI code, because it more than enough here to demonstrate a simple way to keep the GUI and Controller code seperate, and having the GUI code know nothing about anything except itself.
Mark
 
Andrew Douglas
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Mark.
I got it.
Andrew.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic