Java Reference
In-Depth Information
protected JTable createTable(String[] colNames,int nRows){
String[][] rowData = new String[nRows][colNames.length];
for(int i=0;i<nRows;i++){
for(int j=0;j<colNames.length;j++)rowData[i][j]="";
}
JTable table = new JTable(rowData,colNames);
return table;
}
public Vector parseTable(){
int rows = table.getRowCount();
int cols = table.getColumnCount();
Vector tableValues = new Vector();
if(rows>=0&&cols>=0){
for(int i=0;i<rows;i++){
String rowData = "";
for(int j=0;j<cols;j++){
String field = (String)table.getValueAt(i,j);
if(field.length()>0){
field = fixApostrophes(field);
if(j>0)rowData += ", ";
if(dataTypes[j].equals("CHAR")||
dataTypes[j].equals("VARCHAR"))
rowData += "'"+field+"'";
else
rowData += field;
}
}
if(rowData.length()==0)break;
tableValues.addElement(" ( " + rowData + " );\n");
}
}
Search WWH ::




Custom Search