我已经创建了所需的按钮,面板和框架,现在我想添加所需的一切,但我必须使用getMethod()创建.add方法,但我现在不使用什么参数。还要我是否必须为按钮和面板创建不同的方法,还是有更通用的方法?
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