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:数据库的删除,修改操作笔记:

1         String sql = "delete from t_booktype where id =?" ;
2         PreparedStatement pstmt= con.prepareStatement(sql);
3         pstmt.setString(1, str);
4         return pstmt.executeUpdate();
数据删除

 

        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();
数据修改

 

 

 

 

posted on 2013-05-25 22:38  鱼东鱼  阅读(139)  评论(0编辑  收藏  举报

导航