I want to add data to my own JTable model in runtime. I have the table and add button on my interface. As I understand I cant do it with two dimensional array and want to use Arraylist in my custom made table model but I dont know how to make the constructor if I use such type of data.
static String[] columnNames = {"A", "B", "C"};
static Object data[][] = new Object[15][3];
public MyTableModel() {
super(data, columnNames);
}
this is the constructor for data as two dimansional array but I want to use:
ArrayList<Object[]> data = new ArrayList<Object[]>();
How to make it
One way to do it, is to use
AbstractTableModel. Here is an example:If you need to to modify your
dataList<Object[]>, don’t forget to fire appropriate Table Events.AbstractTableModelcontains them all already.