爱问知识人 爱问教育 医院库

寻求高手帮菜鸟解决JAVA问题

首页

寻求高手帮菜鸟解决JAVA问题


        

提交回答
好评回答
  • 2008-11-12 09:56:00
      使用I/O直接将数据保存在记事本中吧,估计这是最简单的。如果用数据库,30分有点太少了。对于查询的的功能可以用正则表达式将整个记事本的内容进行查找。你可以根据你的要求改一改,用于保存信息的类:import  。FileWriter;import  。
      IOException;public class Io { public static void main(String[] args) { String dir = "d:/index。text";// 文件保存路径 try { FileWriter fw = new FileWriter(dir); String s = "张三 女 040911111 日语051班 山东济南人" + "\r\n"; String s2 = "李四 男 050811111 日语052班 山东德州人" + "\r\n"; fw。
      write(s); fw。write(s2); ose(); } catch (IOException e) { // TODO Auto-generated catch block intStackTrace(); } }}用于查询的类:import 。
      BufferedReader;import 。FileReader;import 。IOException;import 。Reader;public class Lookup { public static void main(String[] args) throws IOException { Reader dir; dir = new FileReader("d:/index。
      text"); BufferedReader fr = new BufferedReader(dir); String s ; while ((s= adLine()) != null) { if( ntains("040911111"))//查找号为040911111的学生信息,如果存在打印出来 intln(s); } ose(); }}。
      

    h***

    2008-11-12 09:56:00

其他答案

    2008-11-12 08:45:00
  • 会,但是一看这分,只能发个言,灌水一下就走人

    k***

    2008-11-12 08:45:00

  • 2008-11-11 20:16:00
  •   说实在的要写全了,就是你给一百分我也不见得愿意帮你写,实在太多了啊,不过我这有个以前的例子真好有点适合你的,和你的基本差不多,你稍微该点数据就可以了package xiangnu;import  t。BorderLayout;import  t。
      GridLayout;import javax。swing。ButtonGroup;import javax。swing。JButton;import javax。swing。JComboBox;import javax。swing。JFrame;import javax。
      swing。JLabel;import javax。swing。JPanel;import javax。swing。JRadioButton;import javax。swing。JTextField;public class AddPanel extends JFrame { private JPanel panAdd,pan,btn; private JLabel labName, labSex, labBir, labMassage, labTel, labEmail, labAdress; private JTextField jtName, jtBir, jtTel, jtMail, jtadress; private JComboBox massage; private JRadioButton jcM,jcF; private JButton btnsure,btnCanel; public AddPanel() { super("添加员工信息"); setSize(320, 230); setLocation(320, 220); setDefaultCloseOperation(JFrame。
      DISPOSE_ON_CLOSE); btnsure=new JButton("确定"); btnCanel=new JButton("取消"); jtName=new JTextField(); jtBir=new JTextField(); jtTel=new JTextField(); jtMail=new JTextField(); jtadress=new JTextField(); labName=new JLabel("姓名"); labSex=new JLabel("性别"); labBir=new JLabel("生日"); labMassage=new JLabel("职位"); labTel=new JLabel("电话"); labEmail=new JLabel("电子邮件"); labAdress=new JLabel("地址"); jcM=new JRadioButton("男"); tSelected(true); jcF=new JRadioButton("女"); ButtonGroup btg=new ButtonGroup(); d(jcM); d(jcF); massage=new JComboBox(); dItem("经理"); dItem("职员"); dItem("临时工"); btn=new JPanel(); panAdd=new JPanel(); pan=new JPanel(); d(jcM); d(jcF); tLayout(new GridLayout(8,2)); d(labName); d(jtName); d(labSex); d(pan); d(labBir); d(jtBir); d(labMassage); d(massage); d(labTel); d(jtTel); d(labEmail); d(jtMail); d(labAdress); d(jtadress); d(btnsure); d(btnCanel); setLayout(new BorderLayout()); d(panAdd,BorderLayout。
      NORTH); this。add(btn,BorderLayout。SOUTH); }public static void main(String[] args) { new AddPanel()。setVisible(true);} }----------------------------------------------------------------------package xiangnu;import t。
      Checkbox;import t。GridLayout;import java。util。ArrayList;import java。util。List;import javax。swing。ComboBoxEditor;import javax。
      swing。JComboBox;import javax。swing。JLabel;import javax。swing。JPanel;import javax。swing。JTextField;public class DisplayPan extends JPanel { private JLabel lblEmpId, lblEmpName, lblEmpGender, lblEmpBirth, lblEmpPosition, lblEmpTel, lblEmpEmail, lblEmpAdd; private JLabel lblEmpIdTitle, lblEmpNameTitle, lblEmpGenderTitle, lblEmpBirthTitle, lblEmpPositionTitle, lblEmpTelTitle, lblEmpEmailTitle, lblEmpAddTitle; private ArrayList al; private int recordNumber; private int recordCount; public DisplayPan(ArrayList al) { setLayout(new GridLayout(4, 4, 0, 30)); = al; recordCount = ze(); lblEmpIdTitle = new JLabel("编号:", JLabel。
      CENTER); lblEmpNameTitle = new JLabel("姓名:", JLabel。CENTER); lblEmpGenderTitle = new JLabel("性别:", JLabel。CENTER); lblEmpBirthTitle = new JLabel("生日:", JLabel。
      CENTER); lblEmpPositionTitle = new JLabel("职位:", JLabel。CENTER); lblEmpTelTitle = new JLabel("电话:", JLabel。CENTER); lblEmpEmailTitle = new JLabel("电子邮件:", JLabel。
      CENTER); lblEmpAddTitle = new JLabel("地址:", JLabel。CENTER); lblEmpId = new JLabel(); lblEmpName = new JLabel(); lblEmpGender = new JLabel(); lblEmpBirth = new JLabel(); lblEmpPosition = new JLabel(); lblEmpTel = new JLabel(); lblEmpEmail = new JLabel(); lblEmpAdd = new JLabel(); add(lblEmpIdTitle); add(lblEmpId); add(lblEmpNameTitle); add(lblEmpName); add(lblEmpGenderTitle); add(lblEmpGender); add(lblEmpBirthTitle); add(lblEmpBirth); add(lblEmpPositionTitle); add(lblEmpPosition); add(lblEmpTelTitle); add(lblEmpTel); add(lblEmpEmailTitle); add(lblEmpEmail); add(lblEmpAddTitle); add(lblEmpAdd); showEmployee((Employee) t(recordNumber)); } public void setPage() { showEmployee((Employee) t(recordNumber)); } public void first() { recordNumber = 0; setPage(); } public void next() { recordNumber++; if (recordNumber > recordCount - 1) { recordNumber = recordCount - 1; } setPage(); } public void prev() { recordNumber--; if (recordNumber < 0) { recordNumber = 0; } setPage(); } public void last() { recordNumber = recordCount - 1; setPage(); } public void go(int num) { recordNumber = num; if (recordNumber < 0) { recordNumber=0;}if(recordNumber>recordCount-1){recordNumber=recordCount-1;}setPage();}publicvoidshowEmployee(Employeee){tText(tEmpId());tText(tEmpName());tText(tEmpGender()==0?"男":"女");tText(tEmpBirth()。
      toLocaleString());tText(tEmpPosition()=='M'?"经理": tEmpPosition()=='E'?"员工":"零时工");tText(tEmpTel());tText(e。getEmpEmail()); tText( tEmpAdd()); } public int getRecordCount() { return recordCount; } public void setRecordCount(int recordCount) { cordCount = recordCount; } public int getRecordNumber() { return recordNumber; } public void setRecordNumber(int recordNumber) { cordNumber = recordNumber; }}----------------------------------------------------------------------package xiangnu;import java。
      util。Date;public class Employee { private String empId; private String empName; private int empGender; private Date empBirth; private char empPosition; private String empTel; private String empEmail; private String empAdd; public Employee(String i,String n,int g,Date b,char p,String t,String e,String a) { empId = i; empName = n; empGender = g; empBirth = b; empPosition = p; empTel = t; empEmail = e; empAdd = a; } public String getEmpAdd() { return empAdd; } public void setEmpAdd(String empAdd) { this。
      empAdd = empAdd; } public Date getEmpBirth() { return empBirth; } public void setEmpBirth(Date empBirth) { this。empBirth = empBirth; } public String getEmpEmail() { return empEmail; } public void setEmpEmail(String empEmail) { this。
      empEmail = empEmail; } public int getEmpGender() { return empGender; } public void setEmpGender(int empGender) { this。empGender = empGender; } public String getEmpId() { return empId; } public void setEmpId(String empId) { this。
      empId = empId; } public String getEmpName() { return empName; } public void setEmpName(String empName) { this。empName = empName; } public char getEmpPosition() { return empPosition; } public void setEmpPosition(char empPosition) { this。
      empPosition = empPosition; } public String getEmpTel() { return empTel; } public void setEmpTel(String empTel) { this。empTel = empTel; }}----------------------------------------------------------------------package xiangnu;import t。
      BorderLayout;import t。event。ActionEvent;import t。event。ActionListener;import java。util。ArrayList;import java。util。Date;import javax。
      swing。JButton;import javax。swing。JFrame;import javax。swing。JPanel;import javax。swing。JTextField;public class MainFrame extends JFrame implements ActionListener { private DisplayPan displayPan; private JPanel pagePan; private JButton btnFirst, btnNext, btnPrev, btnLast, btnGoTo,add; private JTextField txfRecordNumber; public MainFrame() { // TODO Auto-generated constructor stub setTitle("职员信息管理"); setDefaultCloseOperation(JFrame。
      EXIT_ON_CLOSE); setSize(400, 300); setLocation(300,200); setLayout(new BorderLayout()); ArrayList al = new ArrayList(); Employee e = new Employee("E-19801211-34323", "张三", 0, new Date(), 'M', "12345678", "", ""); Employee e1 = new Employee("E-19810513-12531", "李四", 0, new Date(), 'T', "12345678", "", "432"); Employee e2 = new Employee("E-32131232-43521", "王五", 0, new Date(), 'M', "12345678", "12", "432"); Employee e3 = new Employee("E-34324231-12341", "周六", 0, new Date(), 'E', "12345678", "", "432"); a d(e); d(e1); d(e2); d(e3); displayPan = new DisplayPan(al); add(displayPan, BorderLayout。
      NORTH); pagePan = new JPanel(); btnFirst = new JButton("<<"); btnPrev = new JButton("<"); btnNext = new JButton(">"); btnLast = new JButton(">>"); btnGoTo = new JButton("GO"); add=new JButton("添加"); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); dActionListener(this); txfRecordNumber = new JTextField("" + ( tRecordNumber() + 1), 3); d(btnFirst); d(btnPrev); d(btnNext); d(btnLast); d(txfRecordNumber); d(btnGoTo); d(add); add(pagePan, BorderLayout。
      CENTER); } public static void main(String[] args) { new MainFrame()。setVisible(true); } public void actionPerformed(ActionEvent e) { if( tActionCommand()=="添加"){ AddPanel add=new AddPanel(); tVisible(true); } if ( tSource() == btnFirst) { rst(); } if ( tSource() == btnPrev) { ev(); } if ( tSource() == btnNext) { xt(); } if ( tSource() == btnLast) { st(); } if ( tSource() == btnGoTo) { int num = rseInt( tText()); displayPan。
      go(num); } tText("" + ( tRecordNumber() + 1)); }}----------------------------------------------------------------------总共四个类,自己复制好导入到工具里面自己看!!能写就自己写一编,加油!。
      

    c***

    2008-11-11 20:16:00

  • 2008-11-11 17:15:00
  • 这要用到文件输入流输出流方面的知识。写起来是很麻烦的。不好意思哦,就不能一点一点帮你啦。不过你可以问你的老师呀!加油!

    z***

    2008-11-11 17:15:00

类似问题

换一换
  • 互联网 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):