At 01:31 PM 1/9/2002, Samir wrote: >You can try to instantiate the class as follows > >if (componentType.equals("JButton")) >{ > JButton compName = (JButton) > Class.forName("JButton").getConstructor(new > Class[]{String.class}).newInstance(new Object[]{label});
First off all, this will not work. The value passed to forName() should be a fully qualified class name, i.e. "javax.swing.JButton". Second, since the set of component types Alex is creating is finite and small, there is no reason to do this sort of run-time instantiation. What Alex is currently doing is just fine. The only recommendation I'd have is to implement this as a Factory pattern. Regards Dmitry _______________________________________________ Advanced-swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/advanced-swing