给jtable加一个鼠标双击事件
JTable table = null; table.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
//没有选中行,返回
if(table.getSelectedRow()<0){
return;
}
//是否为左键双击,不是则返回
if(!((SwingUtilities.isLeftMouseButton(e))&&(e.getClickCount()==2))){
return;
}
JTable table = null; table.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
//没有选中行,返回
if(table.getSelectedRow()<0){
return;
}
//是否为左键双击,不是则返回
if(!((SwingUtilities.isLeftMouseButton(e))&&(e.getClickCount()==2))){
return;
}
一个是象在其他类中一样,在代码中连接数据库
另一个是用这样的方法与servlet建立连接,把结果集写如流中传给相应的servlet中,在servlet中执行数据库操作
URL url = new URL("servlet");
URLConnection urlcon = url.openConnection();
urlcon.connect();
一种是行入口数据对象
也就是table中一行对应一个数值对象
获得这个数值对象,就用JDBC写入到数据库中
一种是表入口数据对象
一个table中所有的数据储存在一个对象中
每行的数据可以是一个对象或者是一个集合
然后放在一个更大的集合中
存储时要作些判断或者是循环来保存
看来大哥是高手,能不能给个类似操作的源代码,有点过分,但小妹我也是任务紧呀!!
emil:[email protected]
然后再向数据库写入。 public boolean saveRecord( Vector vec)
{
Statement statement;
try{
statement = connection.createStatement();
String strSqlAdd = "INSERT INTO tOutlay ("+ "kDate,Goods,Moneys,Owner,Flag,Re"+
") VALUES ( '"+ vec.elementAt(0) + "', '" + vec.elementAt(1)+ "', " + vec.elementAt(2) +
", '" + vec.elementAt(3)+ "', '" + vec.elementAt(4)+ "', '" + vec.elementAt(5)+ "')"; if( statement.executeUpdate(strSqlAdd)==1) {
statement.close();
return true;
}
} catch( SQLException sqlex ) {
sqlex.printStackTrace();
}
return false;
}
是这个:
http://community.csdn.net/Expert/topic/3368/3368586.xml?temp=.8514063
已经有一些答复了,你看看给我点建议