Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
class TablaModelo extends AbstractTableModel {
String[] columnNames = {};
Vector rows = new Vector();
Vector clases = new Vector();
public TablaModelo(Vector columnNames, Vector rows){
String [] cn = new String [columnNames.size()];
for(int i=0;i<columnNames.size();i++){
cn[i]=(String) columnNames.elementAt(i);
clases.add(String.class);
}
this.columnNames=cn;
this.rows=rows;
}
public void addRow(Vector r) {
rows.add(r);
}
public void deleteRow(int index) {
rows.remove(index);
}
public void deleteAllRows(){
rows.removeAllElements();
}
//////////////////////////////////////////////////////////////////////////
//
// Implementation of the TableModel Interface
//
//////////////////////////////////////////////////////////////////////////
public String getColumnName(int column) {
if (columnNames[column] != null) {
return columnNames[column];
} else {
return "";
}
}
public Class getColumnClass(int column) {
return (Class) clases.elementAt(column);
}
public void setColumnClass(Class clase, int column){
clases.setElementAt(clase,column);
}
public boolean isCellEditable(int row, int column) {
return true;
}
public int getColumnCount() {
return columnNames.length;
}
// Data methods
public int getRowCount() {
return rows.size();
}
public Object getValueAt(int aRow, int aColumn) {
Vector row = (Vector)rows.elementAt(aRow);
return row.elementAt(aColumn);
}
public void setValueAt(Object value, int row, int column) {
Vector dataRow = (Vector)rows.elementAt(row);
dataRow.setElementAt(value, column);
fireTableChanged(new TableModelEvent(this, row, row, column));
}
}