数据库实验完整版 通讯录

上传者: u011277745 | 上传时间: 2022-05-21 14:09:27 | 文件大小: 13.61MB | 文件类型: ZIP
package main; import java.awt.Color; import java.awt.Font; import java.awt.Image; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.*; public class addWind implements ActionListener { private JFrame wind; //定义保存用户输入的姓名 private String getname; //定义标签数组 private JLabel[] lbArray={ new JLabel("请输入您要新增的信息内容:"), new JLabel("姓 名:"), new JLabel("性 别:"), new JLabel("出生日期:"), new JLabel("手机号码:"), new JLabel("MSN/QQ:"), new JLabel("现在住址:"), new JLabel("家 乡:"), new JLabel("关 系:"), new JLabel("备 注:")}; //定义文本域数组 private JTextField[] jtfArray={ new JTextField(), new JTextField(30), new JTextField(30), new JTextField(30), new JTextField(30), new JTextField(30), new JTextField(30), new JTextField(30), new JTextField(30), new JTextField(30) }; private JButton btn,btn2; //构造函数 public addWind() { wind = new JFrame("新增通讯信息页面"); wind.setSize(600,600); btn = new JButton("确认添加"); btn2 = new JButton("返回"); wind.setLayout(null); btn.setBounds(220,500,100,30); btn2.setBounds(360,500,100,30); wind.add(btn); wind.add(btn2); addComponent(); addListener(); Image icon = Toolkit.getDefaultToolkit().getImage("./image/test.PNG"); wind.setIconImage(icon); wind.setVisible(true); //wind.setBackground(Color.red); wind.setLocationRelativeTo(null); wind.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) { int temp = JOptionPane.showConfirmDialog(wind, "您是要退出系统,还是返回登录?", "请选择退出或者登录?", JOptionPane.WARNING_MESSAGE); if(temp==0) { System.exit(0); }else { wind.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); } } }); } public void addComponent() { lbArray[0].setFont(new Font("楷体",Font.BOLD+Font.ITALIC,22)); lbArray[0].setForeground(Color.red); lbArray[0].setBounds(100,10,800,20); for(int i=1;i<10;i++) { lbArray[i].setBounds(60,i*50,150,30); lbArray[i].setFont(new Font("楷体",Font.BOLD,20)); lbArray[i].setForeground(Color.blue); jtfArray[i].setBounds(210,i*50,300,30); wind.add(jtfArray[i]); } for(int i=0;i<10;i++) { wind.add(lbArray[i]); } } //注册监听器 public void addListener() { btn.addActionListener(this); btn2.addActionListener(this); for(int i=0;i<10;i++) { jtfArray[i].addActionListener(this); } } //实现ActionListener接口 public void actionPerformed(ActionEvent e) { if(e.getSource()==btn) { //点击更新按钮的操作 getname=jtfArray[1].getText().trim(); System.out.println("test:"+getname); if(getname!=null&&!getname.equals("")) { //拼装SQL语句 String sql = "select name from memoData where name='"+getname+"';"; System.out.println("要更新姓名是:"+getname); DBTool.initialConnect(); if( DBTool.checkData(sql,getname,wind)); { //定义正则表达式,验证电话号码有效性 String parten="1[3|5|8]\\d{9}"; String uname=jtfArray[1].getText().trim(); String sex=jtfArray[2].getText().trim(); String birth=jtfArray[3].getText().trim(); String mobile=jtfArray[4].getText().trim(); if(mobile.matches(parten)) { }else { JOptionPane.showMessageDialog(wind, "您输入的电话号码有误,请检查后再试。", "温馨提示:", JOptionPane.WARNING_MESSAGE); return ; } String msn=jtfArray[5].getText().trim(); String address=jtfArray[6].getText().trim(); String home=jtfArray[7].getText().trim(); String extend=jtfArray[8].getText().trim(); String others=jtfArray[9].getText().trim(); //拼装SQL语句 sql="insert into memoData values('"+uname+"', "+ "'"+sex+"',"+"'"+birth+"', "+"'"+ mobile+"' ,"+"'"+msn+"', "+"'"+address+"' ,"+"'" +home+"', "+"'"+extend+"' ,"+"'"+others+"');"; DBTool.initialConnect(); DBTool.insertData(sql,wind); } }else { JOptionPane.showMessageDialog(wind, "姓名不能为空哦。。", "温馨提示:", JOptionPane.WARNING_MESSAGE); } }else if(e.getSource()==btn2) { //点击返回按钮的操作 new MainWind(); wind.dispose(); }else if(e.getSource()==jtfArray[0]) { jtfArray[1].requestFocus(true); }else if(e.getSource()==jtfArray[1]) { jtfArray[2].requestFocus(true); }else if(e.getSource()==jtfArray[2]) { jtfArray[3].requestFocus(true); }else if(e.getSource()==jtfArray[3]) { jtfArray[4].requestFocus(true); }else if(e.getSource()==jtfArray[4]) { jtfArray[5].requestFocus(true); }else if(e.getSource()==jtfArray[5]) { jtfArray[6].requestFocus(true); }else if(e.getSource()==jtfArray[6]) { jtfArray[7].requestFocus(true); }else if(e.getSource()==jtfArray[7]) { jtfArray[8].requestFocus(true); }else if(e.getSource()==jtfArray[8]) { jtfArray[9].requestFocus(true); }else if(e.getSource()==jtfArray[9]) { btn2.requestFocus(true); } } }

文件下载

资源详情

[{"title":"( 44 个子文件 13.61MB ) 数据库实验完整版 通讯录","children":[{"title":".project <span style='color:#111;'> 389B </span>","children":null,"spread":false},{"title":"bin","children":[{"title":"main","children":[{"title":"changePassWind.class <span style='color:#111;'> 6.07KB </span>","children":null,"spread":false},{"title":"DBTool.class <span style='color:#111;'> 7.79KB </span>","children":null,"spread":false},{"title":"MainWind.class <span style='color:#111;'> 9.15KB </span>","children":null,"spread":false},{"title":"registWind.class <span style='color:#111;'> 8.16KB </span>","children":null,"spread":false},{"title":"checkAll$1.class <span style='color:#111;'> 1.17KB </span>","children":null,"spread":false},{"title":"addWind.class <span style='color:#111;'> 5.67KB </span>","children":null,"spread":false},{"title":"registWind$1.class <span style='color:#111;'> 1.05KB </span>","children":null,"spread":false},{"title":"MainWind$1.class <span style='color:#111;'> 1.02KB </span>","children":null,"spread":false},{"title":"checkWind.class <span style='color:#111;'> 6.64KB </span>","children":null,"spread":false},{"title":"deleteWind.class <span style='color:#111;'> 4.15KB </span>","children":null,"spread":false},{"title":"LoginWind.class <span style='color:#111;'> 5.74KB </span>","children":null,"spread":false},{"title":"deleteWind$1.class <span style='color:#111;'> 1.05KB </span>","children":null,"spread":false},{"title":"queryWind.class <span style='color:#111;'> 4.79KB </span>","children":null,"spread":false},{"title":"addWind$1.class <span style='color:#111;'> 1.03KB </span>","children":null,"spread":false},{"title":"changePassWind$1.class <span style='color:#111;'> 1.05KB </span>","children":null,"spread":false},{"title":"checkWind$1.class <span style='color:#111;'> 1.05KB </span>","children":null,"spread":false},{"title":"checkAll.class <span style='color:#111;'> 2.72KB </span>","children":null,"spread":false},{"title":"updataAll$1.class <span style='color:#111;'> 1.15KB </span>","children":null,"spread":false},{"title":"updataAll.class <span style='color:#111;'> 1.03KB </span>","children":null,"spread":false},{"title":"queryWind$1.class <span style='color:#111;'> 1.18KB </span>","children":null,"spread":false},{"title":"LoginWind$1.class <span style='color:#111;'> 1.05KB </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"DataBaseSql.txt <span style='color:#111;'> 12.37KB </span>","children":null,"spread":false},{"title":".settings","children":[{"title":"org.eclipse.jdt.core.prefs <span style='color:#111;'> 598B </span>","children":null,"spread":false}],"spread":true},{"title":"数据库实验.jar <span style='color:#111;'> 605.29KB </span>","children":null,"spread":false},{"title":"image","children":[{"title":"love2.gif <span style='color:#111;'> 169.35KB </span>","children":null,"spread":false},{"title":"love3.gif <span style='color:#111;'> 5.26MB </span>","children":null,"spread":false},{"title":"love.gif <span style='color:#111;'> 4.93MB </span>","children":null,"spread":false},{"title":"love4.gif <span style='color:#111;'> 1.94MB </span>","children":null,"spread":false},{"title":"test.PNG <span style='color:#111;'> 141.22KB </span>","children":null,"spread":false}],"spread":true},{"title":"src","children":[{"title":"main","children":[{"title":"checkWind.java <span style='color:#111;'> 6.97KB </span>","children":null,"spread":false},{"title":"DBTool.java <span style='color:#111;'> 9.58KB </span>","children":null,"spread":false},{"title":"deleteWind.java <span style='color:#111;'> 3.37KB </span>","children":null,"spread":false},{"title":"updataAll.java <span style='color:#111;'> 1.05KB </span>","children":null,"spread":false},{"title":"LoginWind.java <span style='color:#111;'> 5.07KB </span>","children":null,"spread":false},{"title":"addWind.java <span style='color:#111;'> 5.60KB </span>","children":null,"spread":false},{"title":"changePassWind.java <span style='color:#111;'> 5.41KB </span>","children":null,"spread":false},{"title":"checkAll.java <span style='color:#111;'> 2.00KB </span>","children":null,"spread":false},{"title":"queryWind.java <span style='color:#111;'> 3.67KB </span>","children":null,"spread":false},{"title":"registWind.java <span style='color:#111;'> 9.72KB </span>","children":null,"spread":false},{"title":"MainWind.java <span style='color:#111;'> 8.54KB </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"MeterDataFinal.jar <span style='color:#111;'> 607.15KB </span>","children":null,"spread":false},{"title":".fatjar <span style='color:#111;'> 371B </span>","children":null,"spread":false},{"title":".classpath <span style='color:#111;'> 371B </span>","children":null,"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明