• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

AbstractTableModel how to read in header and row

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how would I be able to read in my Vector header and rows to this TableModel as in
DefaultTableModel model = new DefaultTableModel(rows, header);
TableModel model = new AbstractTableModel() {
public String getColumnName(int column) {
return (String)header.elementAt(column);
}
public int getRowCount() {
return rows.size();
}
public int getColumnCount() {
return header.size();
}
public Object getValueAt(int row, int column) {
String[] rowData = (String [])elementAt(row);
return rowData[column];
}
public boolean isCellEditable(int row, int col) {
return (col==1);
}
public void setValueAt(Object value, int row, int column) {
String newValue = (String)value;
String[] rowData = (String [])elementAt(row);
rowData[column] = newValue;
fireTableCellUpdated(row, column); //table event
}
};
Gina
 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic