I need to get some ideas from the experts. I have a JTree with three nodes; every time a node is selected, it has to execute some task. For instance, if node A is selected, action A is invoked. If node B is selected, action B is called. You get the idea. I am wondering is there any design pattern that I can use to implement this scenario. I don't want to have a bunch of 'if' statements for checking the node to determine what action needs to call. If any one knows of anything that can help me, pls. let me know.
Each of your nodes could implement the same interface (call it Node), and this interface can have a method on it (call it action()). That way all code that deals with Nodes can treat the the same and simply call the action() method on each Node and have it take the appropriate action.
Originally posted by Sujatha Kumar: Please ignore my previous posting.
You can delete your own posts - just click on the edit/delete icon of the post (the second from right on the top).
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus