Anyone can comment, so leave your views

Friday, September 19, 2008

StringTableModel1Col JAVA jtable table model for one column of data all of type string

/**
*

StringTableModel1Col JAVA jtable table model for one column of data all of type string

@author tushar.kapila at gmail .com

*/
package xmltagger.common;
 
import javax.swing.table.*;
import java.util.*; import javax.swing.*;
 

public class StringTableModel1Col extends AbstractTableModel{
 ArrayList<String> data = new ArrayList<String>();// need array of arrays for multi col
 
 public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex){
 
  if(rowIndex >= data.size()){
   int toAdd = rowIndex - data.size();
   for(int i = 0; i < toAdd; i++){
    data.add("");
   }
  }
  data.set(rowIndex,(String)aValue);
 }
 
  public int getRowCount(){
   return data.size();
  }
  public int getColumnCount(){
   return 1;
  }
  public Object getValueAt(int row, int column){
   return data.get(row);
  }
 
}

No comments:

G
 
Forum
Ads by google:











Source code, testing article - one stop shop Software applications written in Java for cell phones, PHP, Java Dot net, PHP & Perl for the web and Vb6, Java, VB6, Perl and Excel VBA for the desktop .

- Tushar G Kapila
Bangalore India 2007 © Remaining page can be removed if you save on your pc or server.

Contributors