日期:2014-05-20 浏览次数:20711 次
((DefaultTableModel) jTable2.getModel()).insertRow(countRows, new Object[]{ "1", "2", "3", "4" });
------解决方案--------------------
int countRows = jTable2.getRowCount();();//获取当前表格总行数 int[] selectRows = jTable2.getSelectedRows int selectRow=jTable2.getSelectedRow();//选中的行数 if (selectRows.length == 0) { ((DefaultTableModel) jTable2.getModel()).insertRow(countRows, new Object[] { "1", "2", "3", "4" }); } else { ((DefaultTableModel) jTable2.getModel()).insertRow(selectRow + 1, new Object[] { "1", "2", "3", "4" }); }