做一个简易的用户管理系统,实现增删改查功能
两个jframe间的数据传输怎么实现?
没有对象类
jtable呈现代码
all.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String sql = "select num as 序号 ,date as 日期 ,name as 姓名,phone as 手机号,sex as 性别 ,age as 年龄 ,history as 病例 from vip";
DUBtil db = new DUBtil();
try {
db.getConnection();
ResultSet rs = db.executeQuery(sql, null);
ResultSetMetaData rsmd = rs.getMetaData();
// 获取列数
int colCount = rsmd.getColumnCount();
// 存放列名
Vector<String> title = new Vector<String>();
// 列名
for (int i = 1; i <= colCount; i++) {
title.add(rsmd.getColumnLabel(i));
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// fitTableColumns(table);
}
// 表格数据
Vector<Vector<String>> data = new Vector<Vector<String>>();
int rowCount = 0;
while (rs.next()) {
rowCount++;
// 行数据
Vector<String> rowdata = new Vector<String>();
for (int i = 1; i <= colCount; i++) {
rowdata.add(rs.getString(i));
}
data.add(rowdata);
}
if (rowCount == 0) {
model.setDataVector(null, title);
} else {
model.setDataVector(data, title);
}
} catch (Exception ee) {
System.out.println(ee.toString());
JOptionPane.showMessageDialog(JF, "【系统异常!】", "失败",0);
} finally {
db.closeAll();
}
}
});
新建功能的代码该怎么完成?
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// int row = main.table.getSelectedRow();
//// String oid = (String)dtm.getValueAt(row, 0);
// String name = (String)namet.getValueAt(row, 1);
// String phone = (String)dtm.getValueAt(row, 2);
// String sex = (String)dtm.getValueAt(row, 3);
// String age = (String)dtm.getValueAt(row, 3);
// String history = (String)dtm.getValueAt(row, 3);
// String str = sd.Insert(oid, oname, ocourse, odegree);
// JOptionPane.showMessageDialog(null, str);
}
});