1
I am doing a project in java swing in which I have to use a JTable.
默认情况下,jtable可以通过在给出错误输入时变成红色来验证输入(float,int)。 但我想验证在保存按钮单击时留在表中的空单元格。JTable填充行的空单元验证
这里是我的代码:
public boolean validCheck()
{
if (jTable.getCellEditor() != null) {
jTable.getCellEditor().stopCellEditing();
}
for (int i = 0; i < jTable3.getRowCount(); i++)
{
for (int j = 0; j < jTable3.getColumnCount(); j++)
{
String val = jTable3.getValueAt(row, col).toString();
if (val.trim().length() == 0)
{
return false;(joptionpane.showmessagedialog(null,"field empty");)
}
}
}
return true;
}
此代码检查表中的所有行和显示领域的空消息。我需要检查只填充的行(有数据的行)不是jtable中的所有行。
任何建议将有所帮助。
嗨,感谢您的回复.. –
我怎样才能得到有数据的行... –
你能给我一个提示,只有数据的行。 –