I started playing around with Java Reflection and I am boggled as to why is my parent app closes when I close the child app's gui? Anyone care to explain and what should I do with my code?
URL url = new File(System.getProperty("user.dir")+"\\plugins\\"+plugins).toURI().toURL();
URL[] urls = new URL[]{url};
ClassLoader cl = new URLClassLoader(urls);
Class cls = cl.loadClass(mainclass);
Object plugs = cls.newInstance();
System.out.println("EXECUTING PLUGIN...");
Method meths = plugs.getClass().getMethod("getClassControl", JPanel.class);
meths.invoke(plugs, jPanel1);
System.out.println(plugins+" PLUGIN LOADED...");
This code is inside the parent app which is a jframe with a jpanel. What the involked method does is it passes the jpanel object to the class and the class adds a jbutton that has an action to display the child jframe.
whenever I try to close the child jframe, the whole process is terminated. I also tried changing the close operation of the child jframe to dispose yet it yields the same result.
Aucun commentaire:
Enregistrer un commentaire