When I try to initialize an array of javax.swing.JTextField
objects in the constructor, I get a warning about an illegal forward reference.
I understand that the automatically created JTextField
variables don't exist yet. But how can I still have a global array of these objects available in my program?
public class HRDatabase extends javax.swing.JFrame {
private javax.swing.JTextField[] fields;
public HRDatabase() {
fields = {firstNameField, lastNameField, emailField};
}
The variables firstNameField
, lastNameField
, emailField
are basically Swing GUI textfields that are declared automatically by NetBeans.