I am trying to insert Dynamic Rows from Array. I am using following code given on Oracle site:
class mYModel extends AbstractTableModel
{
Object rowData[][] = { {Boolean.TRUE ,"11","OMF","C++","Jhon Doe",22}};
Object[] arr = new Object[5];
String columnNames[] = {
"Action",
"Pages",
"Name",
"Title",
"Author",
"TimeStamp"
};
public int getColumnCount() {
return columnNames.length;
}
public String getColumnName(int column) {
return columnNames[column];
}
public int getRowCount() {
return rowData.length;
}
public Object getValueAt(int row, int column) {
return rowData[row][column];
}
public Class getColumnClass(int column) {
return (getValueAt(0, column).getClass());
}
@Override
public void setValueAt(Object value, int row, int column) {
rowData[row][column] = value;
}
@Override
public boolean isCellEditable(int row, int column) {
return (column == 0);
}
}
What I want that rowData[][] gets value dynamically rather than I initialize it. I am not used to of Java so could not grasp the idea of doing it.
I am not particularly interested to use AbstractModel, if there's some other way around then most welcome to guide me.