I have populated a JTable from file. After populating data into JTable i can edit the
data but the changes i made to the data are not applied. I want the changes to be applied and later i want to save the updated data into file.
Below is the code to populate the table
ArrayList arrayList1 = new ArrayList();
ArrayList arrayList = new ArrayList();
reader = new BufferedReader( new InputStreamReader( new FileInputStream( mainpath ) ) );
Map<String, Object[]> result = new LinkedHashMap<String, Object[]>();
int count = 0;
int i = 0;
boolean b = false;
int r1 = rcount - 1;
while( reader.ready() ) {
String line = reader.readLine();
if( count == 0 )
count++;
else {
String[] values = line.split( "," );
String vit = values[0];
String amt = values[1];
String rda = values[2];
String brand = values[3];
String product = values[4];
int rcount1 = Integer.parseInt( values[5] );
if( rcount1 == r1 ) {
if( result.containsKey( vit ) ) {
result.clear();
result.put( vit, new Object[] { b, vit, amt, rda } );
arrayList = new ArrayList( result.values() );
for( Object v : arrayList ) {
arrayList1.add( v );
}
} else {
if( arrayList.size() > 0 ) {
arrayList.clear();
result.clear();
}
result.put( vit, new Object[] { b, vit, amt, rda } );
arrayList = new ArrayList( result.values() );
for( Object v : arrayList ) {
arrayList1.add( v );
}
}
combo.setSelectedItem( brand );
combo1.setSelectedItem( product );
}
}
}
jTable3.setModel( new AnimalTableModel( arrayList1 ) );
First column is a checkbox, second col a combobox, third col accepts floats, fourth accepts integers.
Any suggestions would be really helpful….
Thanks in advance
to add an item…