The following code is returning null:
private JComponent setupComponent(Class<? extends JComponent> c, Object... constructor) {
try {
return c.getConstructor(new Class[] { c.getClass() }).newInstance(constructor);
}
catch (Exception e) { }
return null;
}
I am calling it here:
JTextField userText = (JTextField) setupComponent(JTextField.class, "Test");
Why is it returning null and how can I fix it?