Since you create the JTable with an matrix for data and array for the columns I figured there should be a way to after created the JTable adding an array (row). Or how is it meant to add a row with Strings?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You cannot add to a JTable directly, you have to get the underlying TableModel. You get this by calling
JTable.getModel(). TableModel is an interface, in a standard JTable it’s implementation is DefaultTableModel. So you have to cast the underlying TableModel to a DefaultTableModel, and then you can applyDefaultTableModel.addRow( Object[] ). (You do, of course, check that the cast is safe and all that).