I have one Mediator.java which do all the functions. And there is RecordGenerationJPanel.java to save the information of a record.NewApplicationJPanel.java is main screen and when I click jbtnGenerate in it, it will show RecordGenerationJPanel and do the showGern method in Mediator class.
All the methods have done by another developer and I have asked to make a new class which will function like showGern method. New showGern class should do some combo box disabled and it also include new text field. But it will be invoked only a checkbox in main screen(NewApplicationJPanel) is checked. Otherwise, it will call the original showGern Method.
Do I need to create another RecordGenerationJPanel? Or, can I do it in same RecordGenerationJPanel? If it’s same, how should I do to show different enabling or disabling and hiding some text field according to condition.
Usually, if RecordGenerationJPanel and the requested new class share some attributes and methods, those attributes and methods should be in one class and used by both. So if theres’s a future change requirement of a bug fix that affects those common parts, you just have to do it once and both panels benefit from the single fix.
In your case, I’d really copy the existing RecordGenerationJPanel to a new class and modify it to meet you requirements.
If it works, you can start a refactoring and extract the common parts to a new class.