lundi 1 février 2016

getMethod() arguments to add components

I have created the required buttons,panels and the frame and now i want to add everything where it needs to,but i have to create the .add method using the getMethod() but i dont now what arguments to use.Also do i have to create different methods for the buttons and the panels or is there something more general?

Class frame = Class.forName(frame_path);
Object obj = frame.newInstance();
Method meth = frame.getMethod("setVisible", Boolean.TYPE);
Method meth2 = frame.getMethod("setDefaultCloseOperation", Integer.TYPE);
meth.invoke(obj, true);
meth2.invoke(obj, EXIT_ON_CLOSE);

Class jb1 = Class.forName(rec_button_path);
Object objJb1 = jb1.newInstance();
Class jb2 = Class.forName(round_button_path);
Object objJb2 = jb2.newInstance();
Class jb3 = Class.forName(rec_button_path);
Object objJb3 = jb3.newInstance();

Class jPanel1 = Class.forName(container_path);
Object objJP1 = jPanel1.newInstance();            
Class jPanel2 = Class.forName(container_path);
Object objJP2 = jPanel2.newInstance();

Method add1 = jPanel1.getMethod(".add", jb1);   // i need helpo here





Aucun commentaire:

Enregistrer un commentaire