I have a class called Database with an arrayList called applicants. Each record in the arrayList applicants is an arrayList of applicant details. (So Database class contains an arrayList of arrayLists).
I also have a class called GUI which contains a JTable:
String[] columnNames = {"Application number",
"Program",
"Name",
"Date",
"Accepted?"};
Object[][] data = {Database.applicants};
Whenever i compile it says: “Non static variable applicants cannot be referenced from a static context”
Any pointers on what i may need to do would be really appreciated.
Thanks in advance.
You are trying to assign an ArrayList to an Array, so you would need to copy the data from the ArrayList to the Array.
Or another option is to create a custom TableModel that uses an ArrayList to hold the data for the model. See the section from the Swing tutorial on Creating a Table Model.