I am having some problems displaying data in an ArrayList in the form of a JTable.
The ArrayList consists of data, but only when the user enters data into JTextField's in a GUI (this GUI is in another class). I have used getText().
My ArrayList is in one class, but the GUI for the JFrame for the JTable is in another class. I can't seem to create a JTable in the GUI and I can't seem to be able to get the data from the ArrayList to be displayed in the JTable.
The ArrayList consists of 12 JTextFields all of which are Strings which should be the Headings for the JTable. When the program is launched, the user is able to enter their own data as many times as they want which is stored in the ArrayList under each Heading. This data is always different as the user enters different data all the time and therefore, I think, I cannot use this:
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
Object[][] data = {
{"Kathy", "Smith",
"Snowboarding", new Integer(5), new Boolean(false)},
{"John", "Doe",
"Rowing", new Integer(3), new Boolean(true)},
{"Sue", "Black",
"Knitting", new Integer(2), new Boolean(false)},
{"Jane", "White",
"Speed reading", new Integer(20), new Boolean(true)},
{"Joe", "Brown",
"Pool", new Integer(10), new Boolean(false)}
};
What do you think I should do? And how should I implement this?
Any help is much appreciated!