I'm having an issue fetching an object from an array of said Object. My code is below. I'm basically trying to build a table and fill in the columns with the data from each object. However currently the table is just showing the object and not the data. See picture:

Table:
public void buildTable(JPanel panel) {
File file = new File("C:\\Users\\user\\Desktop\\test.txt");
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
lineArray = new ArrayList<Person[]>();
while((line = br.readLine()) != null) {
String[] temp = line.split("\\t");
Person p = new Person(temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6], temp[7], temp[8]);
lineArray.add(new Person[]{p});
}
br.close();
} catch (FileNotFoundException e) { e.printStackTrace();}
catch (IOException e) { e.printStackTrace(); }
List<String> columns = new ArrayList<String>();
final List<Person[]> values = new ArrayList<Person[]>();
columns.add("First Name");
columns.add("Last Name");
columns.add("Address");
columns.add("Address 2");
columns.add("City");
columns.add("State");
columns.add("Zip Code");
columns.add("Phone");
columns.add("Email");
for (int i = 0; i < lineArray.size(); i++) {
values.add(lineArray.get(i)); //this is the line where I'm guessing the main problem is
}
TableModel tableModel = new DefaultTableModel(values.toArray(new Object[][] {}), columns.toArray());
final JTable table = new JTable(tableModel);
JScrollPane tableContainer = new JScrollPane(table);
tableContainer.setBounds(10, 36, 833, 219);
panel.add(tableContainer);
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
int selectedRow = table.convertRowIndexToModel(table.getSelectedRow());
contactName.setText((String) table.getValueAt(selectedRow, 0) + " " + table.getValueAt(selectedRow, 1));
contactAddress.setText((String) table.getValueAt(selectedRow, 2));
}
});
}
Object Class:
public class Person {
public String firstName;
public String lastName;
public String address;
public String address2;
public String city;
public String state;
public String zip;
public String phone;
public String email;
public Person(String firstName, String lastName, String address, String address2, String city, String state, String zip, String phone, String email) {
this.firstName = firstName;
this.lastName = lastName;
this.address = address;
this.address2 = address2;
this.city = city;
this.state = state;
this.zip = zip;
this.phone = phone;
this.email = email;
}
}
lineArrayis arraylist ofPersonarray.lineArray = new ArrayList<Person[]>();I think you just have to add Person object to your array list.lineArray.add(new Person[]{p});lineArray.add(p);and define your arraylist aslineArray = new ArrayList<Person>();