java - Adding components to JFrame in Netbeans Swing GUI Builder -
i trying create application using netbeans gui builder, have situation here.
when drag , drop component(jlabel or other used defined component) jpanel palette window of gui builder, java code automatically added netbeans. eg. following code generated:
**private void initcomponents() { jlabel1 = new javax.swing.jlabel(); }** now have arraylist need store component objct added guibuilder. in case object added jlabel1.
arraylist updatecomponentslist = new arraylist(); so need store object in arraylist. infact need new component object automatically added list, whenever new component added guibuilder.
since guibuilder generates java code added component automatically, how make guibuilder update arraylist automatically whenever new component added?
can please me figure out?
thanks in advance.
it might work you. when new components added in current gui, automatically calls initcomponent() method redraw jframe , can updated list of component calling below method @ end of initcomponent() block.
public static list getallcomponents(final container c) {
component[] comps = c.getcomponents(); list<component> complist = new arraylist<component>(); (component comp : comps) { complist.add(comp); if (comp instanceof container) { complist.addall(getallcomponents((container) comp)); } } return complist; }
Comments
Post a Comment