Lost in "java.lang.InstantiationException"
Hi all,
I was wishing someone could orient me in finding the source of this exception in my code. I have a loop that instantiates different classes by their name, doing it without arguments works like a charm, but when adding arguments I get this "java.lang.InstantiationException" exception. The code is like follows:
Code:
java.util.Locale currentLocale = new java.util.Locale ("ES","es");
...
Class newClass = Class.forName(classNameString);
Class[] argsClass = new Class[] {java.util.Locale.class};
Constructor c = newClass.getConstructor(argsClass);
Object[] args = new Object[] {currentLocale};
panelArray[i] = (JPanel) c.newInstance(args);
...
And the constructor of that class looks like follows:
Code:
public class newPanel extends JPanel{
public newPanel(java.util.Locale l){
...
}
...
}
And this is the exception I get:
Code:
java.lang.InstantiationException:
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
...
Anyone got some hint for me?
Many thanks in advance!