Swing0525笔记
1:table的鼠标点击动作:
table有一个getSelectedRow()的方法返回当前选中行数
getValueAt(row, column);调用返回的行数,后面的参数代表table的哪一列
int row = this.bookTypeManagerTable.getSelectedRow(); this.idTxt.setText((String) bookTypeManagerTable.getValueAt(row, 0)); this.bookManagerTxt.setText((String) bookTypeManagerTable.getValueAt( row, 1)); this.bookDescTxt.setText((String) bookTypeManagerTable.getValueAt(row, 2));
2:数据库的删除,修改操作笔记:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 String sql = "delete from t_booktype where id =?" ; 2 PreparedStatement pstmt= con.prepareStatement(sql); 3 pstmt.setString(1, str); 4 return pstmt.executeUpdate();
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
String sql="update t_booktype set bookTypeName=?,bookTypeDesc=? where id=?"; PreparedStatement pstmt= con.prepareStatement(sql); pstmt.setString(1, type.getTypeName()); pstmt.setString(2, type.getTypeDesc()); pstmt.setInt(3, type.getId()); return pstmt.executeUpdate();
我学习JAVA的母校