dimanche 21 avril 2019

How to associate a popup menu item with its functionality

I'm developing a JDBC application, using Java Swing to build the GUI. Once in a window, there are some items which reply to clicking by showing a popup menu with several items. Now I'm facing a design problem, since I don't want to write redundant code or create similar classes. Therefore, I would like to have only one class for the PopUpMenu, and other for its items. My approach then is encapsulating the actions that can be performed by the menu items (maybe classes with an operation Execute() implementing an interface IPopMenuItem), but now I face the problem of linking that functionality to the one provided by the different windows (and those can be of different types), because I can't define a common interface for every one of them... How can I solve this?

Aucun commentaire:

Enregistrer un commentaire