个人通讯录java代码完整版

上传人:油条 文档编号:101453229 上传时间:2019-09-28 格式:DOCX 页数:15 大小:19.80KB
返回 下载 相关 举报
个人通讯录java代码完整版_第1页
第1页 / 共15页
个人通讯录java代码完整版_第2页
第2页 / 共15页
个人通讯录java代码完整版_第3页
第3页 / 共15页
个人通讯录java代码完整版_第4页
第4页 / 共15页
个人通讯录java代码完整版_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《个人通讯录java代码完整版》由会员分享,可在线阅读,更多相关《个人通讯录java代码完整版(15页珍藏版)》请在金锄头文库上搜索。

1、import java.awt.Choice;import java.awt.Container;import java.awt.GridLayout;import java.awt.MenuItem;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.print.Printable;import java.io.BufferedReader;import java.io.File;import java.io.FileNotFoundException;import ja

2、va.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.io.PrintWriter;import java.text.Collator;import java.util.Arrays;import java.util.Comparator;import java.util.Scanner;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.J

3、Label;import javax.swing.JMenuBar;import javax.swing.JMenu;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextArea;import javax.swing.JTextField;import javax.swing.WindowConstants;public class MyAddBook public static JFrame frame;public MyAd

4、dBook()frame=new JFrame(个人通讯录);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);JMenuBar menubar=new JMenuBar();JMenu edit=new JMenu(编辑);JMenuItem edit1=new JMenuItem(录入);JMenuItem edit2=new JMenuItem(查询);JMenuItem edit3=new JMenuItem(删除);JMenuItem edit4=new JMenuItem(修改);

5、JMenuItem edit5=new JMenuItem(排序);edit1.addActionListener(new Typein();JMenu show=new JMenu(显示信息);JMenuItem show1=new JMenuItem(同学);JMenuItem show2=new JMenuItem(同事);JMenuItem show3=new JMenuItem(朋友);JMenuItem show4=new JMenuItem(亲戚);JMenuItem show5=new JMenuItem(全体人员);Container c=frame.getContentPa

6、ne();JPanel pane=new JPanel();c.add(pane);pane.add(menubar);menubar.add(edit);edit.add(edit1);edit.add(edit2);edit.add(edit3);edit.add(edit4);edit.add(edit5);menubar.add(show);show.add(show1);show.add(show2);show.add(show3);show.add(show4);show.add(show5);frame.setSize(300,100);/frame.pack();/查询修改删除

7、class SearchJDialog dialog=new JDialog(frame,查询对话框,true);public Search(String str,int n)dialog.setSize(250,200);Container c=dialog.getContentPane();dialog.setLayout(new GridLayout(2,1,5,5);JLabel Lsearch=new JLabel(请输入要+str+人员的名字:);final JTextField Tname=new JTextField(10);JButton certain=new JButto

8、n(确定);JButton cancel=new JButton(取消);/final String in=Tname.getText();JPanel pane1=new JPanel();JPanel pane2=new JPanel();c.add(pane1);c.add(pane2);pane1.add(Lsearch);pane1.add(Tname);pane2.add(certain);pane2.add(cancel);dialog.setDefaultCloseOperation(dialog.DISPOSE_ON_CLOSE);/dialog.setDefaultClos

9、eOperation(WindowConstants.DISPOSE_ON_CLOSE);if(n=2) certain.addActionListener(new ActionListener() /查询public void actionPerformed(ActionEvent e) try FileReader file=new FileReader(D:AddressBook.txt);Scanner find=new Scanner(file);while(find.hasNext()if(find.next().equals(Tname.getText()dialog.dispo

10、se(); Typein fd=new Typein();fd.frame=new JFrame(查询结果如下);fd.Tname.setText(Tname.getText();fd.Cgroup.select(find.next();fd.Cbirthyear.select(find.next();fd.Cbirthmonth.select(find.next();fd.Cbirthday.select(find.next();fd.Tphone.setText(find.next();fd.Temail.setText(find.next();fd.Tother.setText(find

11、.next();fd.typein();file.close();find.close(); catch (FileNotFoundException e1) / TODO Auto-generated catch block/e1.printStackTrace();System.out.print(未找到文件); catch (IOException e2) / TODO Auto-generated catch block/e2.printStackTrace();System.out.print(未找到该人员); );if(n=3) certain.addActionListener(

12、new ActionListener() /删除public void actionPerformed(ActionEvent e) try File file=new File(D:AddressBook.txt);Scanner find=new Scanner(file);FileWriter file1=new FileWriter(D:AddressBook1.txt,true);PrintWriter write=new PrintWriter(file1);while(find.hasNext()String s=find.next();if(!(s.equals(Tname.getText()write.print(s+t);write.print(find.next()+t);write.print(find.next()+ );write.print(find.next()+ );write.print(find.next()+t);write.print(find.next()+t);write.print(find.next()+t);write.println(find.next();el

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 中学教育 > 其它中学文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号