java学籍管理系统源代码(共5页).doc
精选优质文档-倾情为你奉上package zuoye;/主类import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.Hashtable;public class ManagerWindow extends JFrame implements ActionListener InputStudent 基本信息录入=null; ModifySituation 基本信息修改=null; Inquest 基本信息查询=null; Delete 基本信息删除=null; JPanel pCenter,p,p9; TextField txtName,txtPassword; Label lblTitle,lblName,lblPassword; Button btnSubmit,btnReset,guanbi; Panel p1,p11,p12,p2,p13,p14,p15; JMenuBar bar; ImageIcon icon; JMenu fileMenu; JMenuItem 录入,修改,查询,删除,欢迎,退出,关于; Container con=null; Hashtable 基本信息=null; File file=null; CardLayout card=null; JLabel label=null; JLabel label2; public ManagerWindow() p=new JPanel(); lblName=new Label("管理员帐号:"); txtName=new TextField(10); lblPassword=new Label("密 码:"); txtPassword=new TextField(10); txtPassword.setEchoChar('*'); btnSubmit = new Button("提交"); btnReset = new Button("重置"); guanbi=new Button("关闭"); p11=new Panel(); p12=new Panel(); p13=new Panel(); p14=new Panel(); p15=new Panel(); p11.add(lblName); p11.add(txtName); p12.add(lblPassword); p12.add(txtPassword); txtName.addActionListener(this); txtPassword.addActionListener(this); p13.add(btnSubmit); btnSubmit.setBackground(Color.YELLOW); p13.add(btnReset); btnReset.setBackground(Color.YELLOW); p13.add(guanbi); guanbi.setBackground(Color.YELLOW); btnSubmit.addActionListener(this); btnReset.addActionListener(this); guanbi.addActionListener(this); p.setLayout(new GridLayout(10,1); p.add(p14); p.add(p15); p.add(p11); p.add(p12); p.add(p13); p.setBackground(Color.gray); p9=new JPanel(); icon=new ImageIcon("123.jpg"); label2=new JLabel(icon,JLabel.LEFT); label=new JLabel("欢迎使用学生基本信息管理系统",JLabel.CENTER); label.setFont(new Font("TimesRoman",Font.BOLD,24); label.setForeground(Color.red); p9.setOpaque(true); p9.add(label); p9.add(label2); 录入=new JMenuItem("录入学生基本信息"); 修改=new JMenuItem("修改学生基本信息"); 查询=new JMenuItem("查询学生基本信息"); 删除=new JMenuItem("删除学生基本信息"); 欢迎=new JMenuItem("欢迎界面"); 退出=new JMenuItem("退出"); 关于=new JMenuItem("关于我们"); bar=new JMenuBar(); fileMenu=new JMenu("菜单选项"); fileMenu.add(录入); fileMenu.add(修改); fileMenu.add(查询); fileMenu.add(删除); fileMenu.add(欢迎); fileMenu.add(关于); fileMenu.add(退出); fileMenu.enable(false); bar.add(fileMenu); setJMenuBar(bar); 基本信息=new Hashtable(); 录入.addActionListener(this); 修改.addActionListener(this); 查询.addActionListener(this); 删除.addActionListener(this); 欢迎.addActionListener(this); 退出.addActionListener(this); 关于.addActionListener(this); card=new CardLayout(); con=getContentPane(); pCenter=new JPanel(); pCenter.setLayout(card); pCenter.setBackground(Color.black); file=new File("作业.txt"); if(!file.exists() try FileOutputStream out=new FileOutputStream(file); ObjectOutputStream objectOut=new ObjectOutputStream(out); objectOut.writeObject(基本信息); objectOut.close(); out.close(); catch(IOException e) 基本信息录入=new InputStudent(file); 基本信息修改=new ModifySituation(file); 基本信息查询=new Inquest(this,file); 基本信息删除=new Delete(file); pCenter.add(p,BorderLayout.CENTER); pCenter.add("欢迎语界面",p9); pCenter.add("录入界面",基本信息录入); pCenter.add("修改界面",基本信息修改); pCenter.add("删除界面",基本信息删除); con.add(pCenter,BorderLayout.CENTER); con.validate(); addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0); ); setVisible(true); setBounds(500,200,450,400); validate(); public void clear()txtName.setText("");txtPassword.setText("");SuppressWarnings("deprecation")public void submit()String n=txtName.getText();String paw=txtPassword.getText();if(n.equals("admin") && paw.equals("1234")JOptionPane.showMessageDialog(this,"合法用户,欢迎进入本系统");card.show(pCenter,"欢迎语界面");fileMenu.enable();elseJOptionPane.showMessageDialog(this,"非法用户,禁止进入本系统");public void actionPerformed(ActionEvent e) if(e.getSource()=录入) card.show(pCenter,"录入界面"); else if(e.getSource()=修改) card.show(pCenter,"修改界面"); else if(e.getSource()=查询) 基本信息查询.setVisible(true); else if(e.getSource()=删除) card.show(pCenter,"删除界面"); else if(e.getSource()=欢迎) card.show(pCenter,"欢迎语界面"); else if(e.getSource()=退出) System.exit(0); else if(e.getSource()=关于) JOptionPane.showMessageDialog(this,"五块二小组:常永恒,孙东升,李强,吴春亮,涂留定"); String s=e.getActionCommand();if(s.equals("重置")clear();else if(s.equals("提交")submit();else if(e.getSource()=txtName)txtPassword.requestFocus();else if(e.getSource()=txtPassword)submit();else if(s.equals("关闭")System.exit(0); public static void main(String args) new ManagerWindow(); 专心-专注-专业