Open jDialog problem
I have a jDialog that I use to search over several tables depending on parameters. So I can instantiate to search customer, departments, etc.
Now I want to add a new parameter to be able to add a button that opens the maintenance JDialog for the selected table, so if I instantiate the search jDialog to look for customers, when I press the button open the customers table jDialog,
if I'm looking for departments, open the departments table jDialog.
I think the best way should be pass the class to search dialog and from there instantiate the class, but my problem is I couldn't instantiate a class with two parameters the owner of window and the modal. Any knows how to do ?, I'm trying to avoid to have a hardcoded list of table dialogs nor pass and instantiated JDialog that most of the times wouldn't be used.
and easy view that I want is this
PD:sorry for my poor english
I think this is enough .....
I do agree with you. Those are the most effective way
I've found the trick, here is the summary, of course need to Try/Catch.
//assign to a variable the class of JDialog
Class<? extends JDialog> mant = MyJDialog.class;
//look for the constructor of the parameters I need
Constructor<? extends JDialog> manteniment = mant.getConstructor(Frame.class, Boolean.TYPE);
// instantiate the JDialog
JDialog dialeg = manteniment.newInstance(MyApp.getMainFrame(), true);