Question : operation on JTable

Hello Expert:
                   I am learning how to use JTable to show the data in a database. And at the same time I will provide some funtion on it. For example, add, del, copy and create. And before processing we will at first do a row number test, otherwise the array index out of range exception will be throw out. I want to know why this will occur?

for example row test method :

public int processCRow(int row,Vector<Vector<Object>> tempData){
   
   if(row < 0) {
      row = 0;
   }
 
   if(row > tempData.size()) {
      row = tempData.size();
 }
   
   return row;
   
 }




Answer : operation on JTable

Well, firstly, you wouldn't have a processRow method. You'd have the methods that were real such as deleteRow. If you're trying to delete from an empty Vector, you could simply allow the RuntimeException to be thrown. The most you would do is wrap the Exception in your own custom Exception class
Random Solutions  
 
programming4us programming4us