Java实现同学通信录管理系统.docx

上传人:scccc 文档编号:13261150 上传时间:2021-12-20 格式:DOCX 页数:24 大小:505.66KB
返回 下载 相关 举报
Java实现同学通信录管理系统.docx_第1页
第1页 / 共24页
Java实现同学通信录管理系统.docx_第2页
第2页 / 共24页
Java实现同学通信录管理系统.docx_第3页
第3页 / 共24页
Java实现同学通信录管理系统.docx_第4页
第4页 / 共24页
Java实现同学通信录管理系统.docx_第5页
第5页 / 共24页
点击查看更多>>
资源描述

《Java实现同学通信录管理系统.docx》由会员分享,可在线阅读,更多相关《Java实现同学通信录管理系统.docx(24页珍藏版)》请在三一文库上搜索。

1、.Java程序设计学生通讯录系统设计 计算机Z1111班:张志虎、葛志强2013/12/21同学通信录管理系统一、功能要求:1、信息录入,包括记录的追加和插入; 2、信息删除; 3、信息修改; 4、信息排序和查询; 5、信息的保存和装载; 6、简单的帮助。 系统开发目录:图2-1:系统开发目录二、用例图图2-1:系统用例图三、类图图3-1:系统类图书四、截图及核心代码1、登录模块功能介绍:实现用户的登陆,还包含注册账号和找回密码两个功能。同时可以实现记住密码、自动登陆。 界面展示:图4-1 系统登录核心代码:try String name=cobUserName.getSelectedItem

2、().toString();/获取用户输入的用户名 /输入用户名是否为空 if(name.equals("") JOptionPane.showMessageDialog( null, "用户名不能为空!", "登录失败", JOptionPane.INFORMATION_MESSAGE ); String password=new String(txtPassword.getPassword().trim();/获取用户输入的密码 /输入密码是否为空 if(password.equals("") JOptionP

3、ane.showMessageDialog( null, "密码不能为空!", "登录失败", JOptionPane.INFORMATION_MESSAGE ); return; boolean isMemoryPWD= chbMemoryPWD.isSelected(); boolean isAutoLogon=chbAutoLogon.isSelected(); /System.out.println(isMemoryPWD); User user =new User(name,password); if(user.userLogon()/用户是否

4、存在 UserProperty userp=new UserProperty(user,isMemoryPWD,isAutoLogon); ReadWriteProperties.writeProperties(userp); dispose(); MainFrame mainframe=new MainFrame(user);/启动主操作界面 mainframe.setVisible(true); else /提示失败信息 JOptionPane.showMessageDialog( null, "用户名或密码输入有误!", "登录成功", JOpti

5、onPane.INFORMATION_MESSAGE ); cobUserName.setFocusable(true);/输入用户名的控件获得焦点 txtPassword.setText(null);/输入密码的控件为空 catch(Exception e) l 登录界面-账号注册功能介绍:注册用户界面展示:图4-2 系统用户注册核心代码:public void userRegist() String username=txtUserName.getText().trim(); String password=new String(txtpassword.getPassword().trim

6、(); String passwordok=new String(txtPasswordOk.getPassword(); String id=txtId.getText().trim(); /用户名不能为空 if(username.isEmpty() /提示信息 JOptionPane.showMessageDialog( null, "用户名不能为空!", "用户注册", JOptionPane.INFORMATION_MESSAGE ); return ; /用户名为518 if(username.length()<5|username.le

7、ngth()>18) /提示信息 JOptionPane.showMessageDialog( null, "用户名长度应在518之间!", "用户注册", JOptionPane.INFORMATION_MESSAGE ); return ; User user=new User(username,password,id); try if(user.userRegist() /提示失败信息 JOptionPane.showMessageDialog( null, "注册成功!", "注册成功", JOpti

8、onPane.INFORMATION_MESSAGE ); dispose(); SuppressWarnings("unused") LogonFrame logon =new LogonFrame(); else /提示失败信息 JOptionPane.showMessageDialog( null, "此注册用户已存在!", "注册失败!", JOptionPane.INFORMATION_MESSAGE ); txtUserName.setFocusable(true); catch (FileNotFoundExceptio

9、n e) / TODO Auto-generated catch block e.printStackTrace(); l 登录界面找回密码功能介绍:用户忘记密码,可以通过验证用户名和身份证号找回密码界面展示:图4-3 系统找回密码核心代码:public void userfindPwd() String username =txtUserName.getText().trim(); String id=txtId.getText().trim(); /用户名不能为空 if(username.isEmpty() /提示信息 JOptionPane.showMessageDialog( null

10、, "用户名不能为空!", "用户注册", JOptionPane.INFORMATION_MESSAGE ); return ; /用户名为518 if(username.length()<5|username.length()>18) /提示信息 JOptionPane.showMessageDialog( null, "用户名长度应在518之间!", "用户注册", JOptionPane.INFORMATION_MESSAGE ); return ; /身份证号不能为空 /身份证号不是18位时

11、/验证身份证号 User user =new User(); user.setUsername(username); user.setId(id); try User userr=user.userFindPwd(); if(userr=null) JOptionPane.showMessageDialog( null, "用户名或身份证号有误!", "找回密码失败", JOptionPane.INFORMATION_MESSAGE ); else JOptionPane.showMessageDialog( null, "用户名:"

12、+userr.getUsername()+"rn密码:"+new String(userr.getPassword().trim(), "找回密码成功", JOptionPane.INFORMATION_MESSAGE ); catch (FileNotFoundException e) / TODO Auto-generated catch block e.printStackTrace(); 2、系统主界面功能介绍:包含系统管理、文件管理、操作管理、其他4个功能模块,具体模块功能后面详细介绍主界面展示:图4-4 系统主操作界面核心代码: /显示关于对

13、话框 JMenuItem mntmAbout = new JMenuItem("u7CFBu7EDFu5173u4E8E"); mnOther.add(mntmAbout); JMenuItem mntmHelp = new JMenuItem("u5E2Eu52A9"); mntmHelp.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) if(!helpFlag) panelHelp.setVisible(true); String st

14、r="系统名称: rn" txtHelpInfor.setText(str); helpFlag=true; else panelHelp.setVisible(false); helpFlag=false; )21.1、系统管理修改密码功能介绍:更改用户密码界面展示:图4-5 系统更改密码核心代码:public void updatepwd() String oldpassword=new String(txtOldPassword.getPassword().trim(); String newpassword=new String(txtNewPassword.get

15、Password().trim(); String passwordok=new String(txtPasswordOk.getPassword().trim(); /旧密码不能为空 if(oldpassword.isEmpty() /提示信息 JOptionPane.showMessageDialog( null, "旧密码不能为空!", "用户更改密码", JOptionPane.INFORMATION_MESSAGE ); return ; /新密码不能为空 /密码为615 /确认密码不能为空 /两次密码不一致 /是否更改密码成功 try if(

16、!user.userUpdatePwd(newpassword) /失败 JOptionPane.showMessageDialog( null, "原密码输入有误!", "密码更改失败", JOptionPane.INFORMATION_MESSAGE ); else/成功 JOptionPane.showMessageDialog( null, "密码更改成功", "密码更改成功", JOptionPane.INFORMATION_MESSAGE ); catch (FileNotFoundException

17、e) / TODO Auto-generated catch block e.printStackTrace(); 21.2、系统管理注销账号功能介绍:退回到登陆界面界面:图4-6 系统管理-注销账号核心代码:mntmLogoff.addActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) dispose(); LogonFrame frame = new LogonFrame(); );21.3、系统管理退出系统功能介绍:退出系统图4-7 系统管理-退出系统核心代码: mntmExi

18、t.addActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) System.exit(0); );22.1、文件管理导入文件功能介绍:导入类型是.TXT类型的通讯记录到通讯系统中界面展示:图4-8 文件管理-导入文件核心代码:okButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) if(v=null) JOptionPane.showMessageDialog

19、( null, "导入失败,请选择文件进行导入", "导入数据", JOptionPane.INFORMATION_MESSAGE ); return; else UseFile.writeFile(fname, v); JOptionPane.showMessageDialog( null, "数据导入成功", "导入数据", JOptionPane.INFORMATION_MESSAGE ); return; );btnSelectFile.addActionListener(new ActionListene

20、r() public void actionPerformed(ActionEvent e) JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("*.txt","txt"); chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(getParent(); String filename=null; if(retur

21、nVal = JFileChooser.APPROVE_OPTION) filename= chooser.getSelectedFile().toString(); txtFilePath.setText(filename);/在文本框中显示文件路径 if(!filename.substring(filename.indexOf(".")+1,filename.length().equals("txt") JOptionPane.showMessageDialog( null, "文件类型必需为*.xls|*.txt", "

22、;文件选择失败", JOptionPane.INFORMATION_MESSAGE ); txtFilePath.setText(""); return; );22.1、文件管理导出文件功能介绍:将在同学通讯录系统中生成的文件以.TXT文件形式导出界面展示:图4-9 文件管理-导出文件核心代码: mntmSava.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) JFileChooser chooser = new JFileChooser(); Fi

23、leNameExtensionFilter filter = new FileNameExtensionFilter("*.txt","txt"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);/选择目录和文件 int returnVal = chooser.showSaveDialog(getParent(); if(returnVal = JFileChooser.APPROVE_OPTION) Stri

24、ng filename = chooser.getSelectedFile().toString();/获取路径 Vector<Classmate> cVector=new Vector<Classmate>(); UseFile.readFile(fname, cVector); if(filename.indexOf('.')<=0) filename+=".txt" if(!filename.substring(filename.indexOf(".")+1,filename.length().equa

25、ls("txt") JOptionPane.showMessageDialog( null, "文件类型必需为*.txt", "导出", JOptionPane.INFORMATION_MESSAGE ); return; UseFile.write(filename, cVector); );23.1、操作管理增加通信记录功能介绍:增加新的同学信息,包括姓名、性别、电话、QQ号、邮箱、备注等界面展示:图4-10 操作管理-添加通信记录核心代码:public void append() boolean flag=true; Strin

26、g name=txtName.getText(); boolean sex=Boolean.parseBoolean(rdbtnMale.isSelected()?"true":"false"); int age=this.sldAge.getValue(); String integrity=this.cobIntegrity.getSelectedItem().toString(); String tel=txtTel.getText(); String qq=txtQQ.getText(); String email=txtEmail.getTex

27、t(); String memo=txtMemo.getText(); if(name.isEmpty() JOptionPane.showMessageDialog( null, "姓名不能为空!", "增加通信信息", JOptionPane.INFORMATION_MESSAGE ); return; else/否,添加新行后,加入新数据。 (javax.swing.table.DefaultTableModel) table.getModel().insertRow(countRows, new Object name, sex, age, in

28、tegrity, tel, qq, email, memo ); row+; table.repaint();/刷新表格数据 Classmate classmate=new Classmate(user.getUsername(),name,sex,age,integrity,tel,qq,email,memo); cVector.add(classmate); UseFile.writeFile(fname, cVector); JOptionPane.showMessageDialog( null, "添加成功!", "增加通信信息", JOptio

29、nPane.INFORMATION_MESSAGE ); txtName.setText(""); txtTel.setText(""); txtQQ.setText(""); 23.2、操作管理删除通信记录功能介绍:通过姓名检索,找出要删除者的全部信息,选择删除或全部删除界面展示:图4-10 操作管理-删除通信记录核心代码:/检索操作public void Select() try if(cVector.size()<=0) JOptionPane.showMessageDialog( null, "没有检索到任何记

30、录!", "删除通信信息", JOptionPane.INFORMATION_MESSAGE ); return; String name; name=txtName.getText(); if(name.isEmpty() tableLoadData();/显示全部通信记录 btnAllDel.setEnabled(true); btnDelete.setEnabled(true); DeleteFalg=true; else SelectByName(name);/姓名检索出要删除的通信记录 btnDelete.setEnabled(true); Delete

31、Falg=false; catch(Exception e) 23.3、操作管理更新通信记录功能介绍:通过姓名检索出要更新的全部信息,然后通过更新相应信息重新设置被检索出来人的信息界面展示:图4-11 操作管理-更新通信记录核心代码:public void Update() boolean flag=true; String name=txtName.getText(); boolean sex=Boolean.parseBoolean(rbtnMale.isSelected()?"true":"false"); int age=this.sldAge.

32、getValue(); String integrity=this.cobIntegrity.getSelectedItem().toString(); String tel=txtTel.getText(); String qq=txtQQ.getText(); String email=txtEmail.getText(); String memo=txtMemo.getText(); if(name.isEmpty() JOptionPane.showMessageDialog( null, "姓名不能为空!", "更新信息", JOptionPa

33、ne.INFORMATION_MESSAGE ); return; if(flag) cVector.remove(cm); cm.setAge(age); cm.setEmail(email); cm.setQq(qq); cm.setTel(tel); cm.setSex(sex); cm.setIntegrity(integrity); cm.setMemo(memo); cVector.add(cm); UseFile.updateFile(fname, cVector); JOptionPane.showMessageDialog( null, "更新信息成功!"

34、, "更新信息", JOptionPane.INFORMATION_MESSAGE ); initFalse(); return; 23.4、操作管理查询通信记录功能介绍:通过查询姓名、性别、组别(关系信息,例如:大学同学),升序或降序将搜索出的信息显示在界面下的表格中界面展示:图4-11 操作管理-查询通信记录核心代码: /升序 JButton btnASC = new JButton("u5347u5E8F"); btnASC.addActionListener(new ActionListener() public void actionPerfo

35、rmed(ActionEvent arg0) OrderbyASC(); ); btnASC.setBounds(418, 66, 93, 23); panel.add(btnASC); /降序 JButton btnDESC = new JButton("u964Du5E8F"); btnDESC.addActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) OrderbyDESC(); );24.1、其他系统关于功能介绍:显示系统的信息界面展示:图4-12其他-关

36、于核心代码:/窗体居中显示 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = this.getSize(); this.setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); contentPanel.setLayout(null); JLabel lblNewLabel = new JLabel("u7CFBu7EDFu540Du79F0uFF1A"); lblNewLabel.setBounds(34, 37, 75, 15); contentPanel.add(lblNewLabel); 24.2、其他帮助功能介绍:基本的用户使用方法介绍界面展示:图4-12 其他-帮助 核心代码:mntmHelp.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1