JTable根据商品下拉框的选择,更新表格当前行的内容并指定焦点

 
  
/**
* 根据商品下拉框的选择,更新表格当前行的内容
*
* @return 无
*/
private synchronized void updateTable() {
Spinfo spinfo = (Spinfo) spComboBox.getSelectedItem();
int row = table.getSelectedRow();
if (row >= 0 && spinfo != null) {
table.setValueAt(spinfo.getId(), row, 1);
table.setValueAt(spinfo.getCd(), row, 2);
table.setValueAt(spinfo.getDw(), row, 3);
table.setValueAt(spinfo.getGg(), row, 4);
table.setValueAt(spinfo.getBz(), row, 5);
table.setValueAt("0", row, 6);
table.setValueAt("0", row, 7);
table.setValueAt(spinfo.getPh(), row, 8);
table.setValueAt(spinfo.getPzwh(), row, 9);
table.editCellAt(row, 6);//指定焦点所在列
}
}

你可能感兴趣的:(java)