Problem implementing the abstractTableModel

Hi:

    I have constructed a JTable using the abstractTableModel but I am having problem implementing some of the mehods of the AbstractTableModel such as setValueAt and getValueAt. Also I need to create a method to insert a row.

Here is a snippet of my code:

public class DataFileTableModel extends AbstractTableModel {
 protected Vector data;
 //protected Vector columnNames ;  
 protected String datafile;
   
 private Vector tableOfVectors = new Vector();  
 private Vector columnNames;
 Vector data_vector = new Vector();

 public DataFileTableModel(String f){
   datafile = f;
   initVectors();  
   }

 public void initVectors() {
     String aLine;
     //tableOfVectors = new Vector();
     columnNames = new Vector();
   try{
       Process ls_proc = Runtime.getRuntime().exec(datafile);
       BufferedReader br = new BufferedReader(new InputStreamReader( ls_proc.getInputStream()));  
        //extract coumn names
       StringTokenizer st1 =
           new StringTokenizer(br.readLine(), "|");
          while(st1.hasMoreTokens())
              columnNames.addElement(st1.nextToken());
            //extract data
           while ((aLine = br.readLine()) != null) {  
             StringTokenizer st2 = new StringTokenizer(aLine, "|");
                while(st2.hasMoreTokens())
                {
                    tableOfVectors.add(st2.nextToken() );
                }
     }
          br.close();  
   }
   catch (Exception e) {
      e.printStackTrace();
     }
 }

 public int getRowCount() {
   return tableOfVectors.size() / getColumnCount();
 
   }

 public int getColumnCount(){
   return columnNames.size();
   }

 public String getColumnName(int columnIndex) {
   String colName = "";

   if (columnIndex <= getColumnCount())
      colName = (String)columnNames.elementAt(columnIndex);

   //return columnNames[columnIndex];
   return colName;
   }
 
 public Class getColumnClass(int columnIndex){
   return String.class;
   }
   
 public boolean isCellEditable(int rowIndex, int columnIndex) {
   return false;
   }
 
 public void insertRow(int index, Object[] element)
 {
     tableOfVectors.add(index,element);
     fireTableRowsInserted(0,0);
 }
 public void removeTask(int startRow,int endRow)
 {
      int tempRow = 0;
     int actualRows = 0;

    if (endRow < startRow)
    {
      tempRow = endRow ;
      endRow = startRow ;
      startRow = tempRow ; }

    if (startRow < 0 || endRow > getRowCount())
    return;

    actualRows = (endRow - startRow) + 1 ;

    // determine the starting point (cell) to start deleting at //
     int colCount = getColumnCount() ;  
     int cell = startRow * colCount ;

    // determine the total number of cells to delete //
    int totColCount = (getColumnCount() * actualRows) ;

    for (int d = 0; d < totColCount; d++)
    {
      tableOfVectors.remove(cell) ;
    }

    fireTableRowsDeleted(startRow,endRow) ;
   }

nutlessAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Well you know what i'd say about that don't you? ;-)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
DefaultTableModel supplies the functionality of adding/deleting rows. If you extend DTM is there any reason why you would need to override set/getValueAt?
0
CEHJCommented:
For that matter, is there any need to *extend* DTM as opposed to simply creating one?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.