I am developing a standalone application in Java using swing API. I need experts guidance in following scenario.
I have a UI which shows some information of an employee.
There are four Operation in a Menu like add emp, edit emp, view emp,delete emp.
I want to use the same GUI for all four actions.
I designed a class which create GUI for above; I have used Singleton design pattern to construct GUI.
As depending on selected operation; in GUI some componants gets disabled or removed or added more and then GUI gets Constructed and shown to User.
I was thinking of passing a string describing the operation to GUI construncor and then do the above things related to componants.But as I have used the Singleton Design pattern its not possible.
What should I do in above scenario, to complete all my requirement?
Which design pattern you suggest to me for above scenario and as well as for constructing the GUI?
Please guide me experts!
Create an Enum with the operations:
And in your GUI create a method:
Other option would be to have sort of a GUI inheritance:
So your abstract class would have the required fields and the subclasses would just enable/disable them.