1. 首页
  2. 编程语言
  3. Java
  4. Java图形用户界面通讯录

Java图形用户界面通讯录

上传者: 2018-12-26 03:27:08上传 RAR文件 99KB 热度 30次
用Java编写的图形用户界面通讯录package myaddressbody; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.Connection; import java.sql.Date; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import javax.swing.JButton; public class Demonstrationacction implements ActionListener { public void actionPerformed(ActionEvent e) { if (((JButton) e.getSource()).getText().equals("显示查询结果")) { String dburl = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)} ;DBQ=main.mdb"; String sql; Connection con; Statement stmt; String nm, sx, mp, ph, em, ca, ha, nb, gp, lbMQ, all; boolean bdr; Date bd; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (java.lang.ClassNotFoundException e2) { System.err.print("ClassNotFoundException:"); System.err.println(e2.getMessage()); } try { con = DriverManager.getConnection(dburl, "", ""); stmt = con.createStatement(); sql = "SELECT*FROM address"; ResultSet ws = stmt.executeQuery(sql); while (ws.next()) { nm = ws.getString(1); sx = ws.getString(2); bd = ws.getDate(3); mp = ws.getString(4); ph = ws.getString(5); ca = ws.getString(6); em = ws.getString(7); ha = ws.getString(8); gp = ws.getString(9); nb = ws.getString(10); lbMQ = ws.getString(11); all = "姓名:" + nm + " 性别:" + sx + " 生日:" + bd + " 移动电话:" + mp + " 固定电话:" + ph + " MSN/QQ:" + lbMQ + " 公司地址:" + ca + " EMail:" + em + " 家庭地址:" + ha + " 组别" + gp + " 备注:" + nb + "\n"; Demonstrationaframe.lbdem.append(all); } stmt.close(); con.close(); } catch (Exception ex) { System.out.println("Exception:" + ex.getMessage()); } } if (((JButton) e.getSource()).getText().equals("退出全部查询")) { Demonstrationaframe.lbdem.setText(""); Demonstrationaframe.demFrame.setVisible(false); } } } ;DBQ=main.mdb"; String sql; Connection con; Statement stmt; String nm, sx, mp, ph, em, ca, ha, nb, gp, lbMQ, all; boolean bdr; Date bd; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (java.lang.ClassNotFoundException e2) { System.err.print("ClassNotFoundException:"); System.err.println(e2.getMessage()); } try { con = DriverManager.getConnection(dburl, "", ""); stmt = con.createStatement(); sql = "SELECT*FROM address"; ResultSet ws = stmt.executeQuery(sql); while (ws.next()) { nm = ws.getString(1); sx = ws.getString(2); bd = ws.getDate(3); mp = ws.getString(4); ph = ws.getString(5); ca = ws.getString(6); em = ws.getString(7); ha = ws.getString(8); gp = ws.getString(9); nb = ws.getString(10); lbMQ = ws.getString(11); all = "姓名:" + nm + " 性别:" + sx + " 生日:" + bd + " 移动电话:" + mp + " 固定电话:" + ph + " MSN/QQ:" + lbMQ + " 公司地址:" + ca + " EMail:" + em + " 家庭地址:" + ha + " 组别" + gp + " 备注:" + nb + "\n"; Demonstrationaframe.lbdem.append(all); } stmt.close(); con.close(); } catch (Exception ex) { System.out.println("Exception:" + ex.getMessage()); } } if (((JButton) e.getSource()).getText().equals("退出全部查询")) { Demonstrationaframe.lbdem.setText(""); Demonstrationaframe.demFrame.setVisible(false); } } }
用户评论
码姐姐匿名网友 2018-12-26 03:27:08

太帅了,这个资源实在是太帅了,让我打开眼界,顶`~~~!我再顶

码姐姐匿名网友 2018-12-26 03:27:08

存储使用了数据库,对我来说用处不算很大。。。不过作者写的很详细,平时学习看看还是可以的

码姐姐匿名网友 2018-12-26 03:27:08

看不太懂,再研究研究

码姐姐匿名网友 2018-12-26 03:27:08

挺好的资源,学习了

码姐姐匿名网友 2018-12-26 03:27:08

只能看源码 运行要密码

码姐姐匿名网友 2018-12-26 03:27:08

值得参考,存储方式比较麻烦