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中的所有行。
任何建議將有所幫助。
嗨,感謝您的回覆.. –
我怎樣才能得到有數據的行... –
你能給我一個提示,只有數據的行。 –