i create JTable in that table value are retrieve from data base (Except fifth column) in fifth column .i enter value through keyboard in fifth column but when getting value again from jtable at that time i am not getting last entered value in fifth column please suggest something my method code bellow
public class TableDataDelete implements ActionListener
{
public void actionPerformed(ActionEvent ee) {
int b = table.getRowCount();
System.out.println("row count" + b);
for (int i = 0; i <b; i++) {
try
{
String str = (String) table.getModel().getValueAt(i, 3);
String str1 = (String) table.getModel().getValueAt(i, 5);
if (!(str1 == null)) {
((DefaultTableModel)table.getModel()).removeRow(i);
table.repaint();
System.out.println("remove row no is"+i);
}
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("array index out of bound exception"+e);
}
}
}
}
当我输入五个单元格的值时,工作代码只能从无法获取最后输入的单元格值的列中获取前四个单元格
最佳答案
您应该使用此代码停止单元格编辑以获取最后一个值
if(table.getCellEditor() != null){
table.getCellEditor().stopCellEditing();
}
关于java - 获取最后一列最后一个单元格值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22663387/