java编写管理系统_用java编写学生信息管理系统
《用java編寫學生信息管理系統》由會員分享,可在線閱讀,更多相關《用java編寫學生信息管理系統(7頁珍藏版)》請在人人文庫網上搜索。
1、用java編寫學生信息管理系統import .*;importimport .*;import .*;import .*;class Stude nt impleme ntsString nu mber, name,specialty,grade,borth,sex;public Stude nt();public void setNumber(Stri ng nu mber) =nu mber;public String getNumber() retur n nu mber;public void setName(Stri ng n ame) =n ame;public String ge。
2、tName() retur n n ame;public void setSex(Stri ng sex) =sex;public String getSex() retur n sex;public void setSpecialty(Stri ng specialty) =specialty;public String getSpecialty() retur n specialty;public void setGrade(Stri ng grade) =grade;public String getGrade() retur n grade;public void setBorth(S。
3、tri ng borth) =borth;public Stri ng getBorth() retur n borth;public class Stude ntMa nager exte nds JFrameJLabel lb=new JLabel (錄入請先輸入記錄,查詢、刪除請先輸入學號,修改是對查詢” +內容改后的保存! ”);static JTextField Jnu mber, Jn ame,Jspecialty,Jgrade,Jborth;static JRadioButt on boy,girl;static Butt on Group group=nu II;static 。
4、JButton Log in, select,delete,update,show;static JPa nel p1,p2,p3,p4,p5,p6,pv,ph;static Stude nt stude nt=n ull;static Hashtable Shashtable=nu II;static File file=n ull;static File In putStream inOne=n ull;static Object In putStream in Two=n ull;static FileOutputStream out One=n ull;static ObjectOut。
5、putStream outTwo=n ull;public Stude ntMa nager()super(學生基本信息管理系統”);Jnu mber =new JTextField(10);Jname =new JTextField(10); Jspecialty=new JTextField(10); Jgrade=new JTextField(10); Jborth=new JTextField(10); group=new ButtonGroup(); boy=new JRadioButton( 男 ,true); girl=new JRadioButton( 女 ,false); (。
6、boy);(girl);Login=new JButton( 錄入 ); select=new JButton( 查詢 ); delete=new JButton( 刪除 ); update=new JButton( 修改 ); show=new JButton( 顯示 ); (new InputAct();(new InquestAct();(new ModifyAct();(new DeleteAct();(new ShowAct();(false); p1=new JPanel();(new JLabel(學號:,);(Jnumber); p2=new JPanel(); (new JL。
7、abel(姓名:,);(Jname); p3=new JPanel();(new JLabel(性別:,);(boy);(girl);p4=new JPanel();(new JLabel(專業:,);(Jspecialty); p5=new JPanel();(new JLabel(年級:,);(Jgrade); p6=new JPanel();(new JLabel(出生:,);(Jborth); pv=new JPanel();(new GridLayout(6,1);(p1);(p2);(p3);(p4);(p5);(p6);ph=new JPanel();(Login);(selec。
8、t);(update);(delete);(show);file=new File( 學生信息 .txt);Shashtable=new Hashtable();if(!()tryFileOutputStream out=new FileOutputStream(file);ObjectOutputStream objectOut=new ObjectOutputStream(out); (Shashtable);();();catch(IOException e)Container con=getContentPane();(new BorderLayout();(lb, ;(pv, ;(p。
9、h, ;setDefaultCloseOperation(EXIT_ON_CLOSE);setBounds(100,100,600,300);setVisible(true);public static void main(String args) new StudentManager();class InputAct implements ActionListenerpublic void actionPerformed(ActionEvent e)(false);String number=;number=();if()0)tryinOne=new FileInputStream(file。
10、);inTwo=new ObjectInputStream(inOne);Shashtable=(Hashtable)();();();catch(Exception ee) 創建散列表出現問題! ); if(number)String warning= 該生信息已存在,請到修改頁面修改! (null,warning, 警告 ,Jquals(” 男)(true);else(true);else(false);String warning= 該學號不存在! ;(null,warning,警告 ,;else(false);String warning= 必須輸入學號! ;(null,warning。
11、,警告 ,;class ModifyAct implements ActionListener public void actionPerformed(ActionEvent e)String number=();String name=();String specialty=();String grade=();String borth=();String sex=null;if()sex=();elsesex=();Student 學生 =new Student();學生 .setNumber(number);學生 .setName(name);學生 .setSpecialty(speci。
12、alty);學生 .setGrade(grade);學生 .setBorth(borth);學生 .setSex(sex);tryoutOne=new FileOutputStream(file);outTwo=new ObjectOutputStream(outOne);(number, 學生 );(Shashtable);();();(null);(null);(null);(null);(null);catch(Exception ee)錄入修改出現異常 !);(false);class DeleteAct implements ActionListenerpublic void act。
13、ionPerformed(ActionEvent e)(false);String number=();if()0)tryinOne=new FileInputStream(file); inTwo=new ObjectInputStream(inOne); Shashtable=(Hashtable)();();();catch(Exception ee)if(number)Student stu=(Student)(number);();();();();if().equals(” 男)(true);else(true);String m=確定要刪除該學生的記錄嗎?”int ok=(nul。
14、l,m, 確認 ,J Jif(ok=(number);tryoutOne=new FileOutputStream(file);outTwo=new ObjectOutputStream(outOne);(Shashtable);();();(null);(null);(null);(null);(null);catch(Exception ee)else if(ok=(null);(null);(null);(null);(null);elseString warning= 該學號不存在! ;(null,warning,n Ak n . 警告 ,;elseString warning= 必須。
15、輸入學號! ;(null,warning,Ap, n . 警告 ,;class ShowAct implements ActionListenerpublic void actionPerformed(ActionEvent e)new StudentShow(file);class StudentShow extends JDialogHashtable 學生散列表 = null;JTextArea 顯示 =null;FileInputStream inOne=null;ObjectInputStream inTwo=null;File file=null;public StudentSho。
16、w(File file)super(new JFrame(), 顯示對話框 );=file;顯示 =new JTextArea(16,30);tryinOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);學生散列表 =(Hashtable)();();();catch(Exception ee)n);if(學生散列表.isEmpty()顯示.append(”目前還沒有學生的信息記錄! else顯示.setText(”學號姓名性別專業年級出生n”);for(Enumeration enm= 學生散列表 .element。
17、s();();)Student stu=(Student)();String sex=;if().equals(男)sex=男;else sex=女;String str=()+,+()+,+sex+,+()+,+()+,+()+n;顯示 .append(str);JScrollPane scroll=new JScrollPane顯示);Container con=getContentPane();(Center,scroll);();setVisible(true);setBounds(200,200,400,300);addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)setVisible(false);。
總結
以上是生活随笔為你收集整理的java编写管理系统_用java编写学生信息管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: U盘远程连接怎么连 U盘连接远程桌面方法
- 下一篇: 怎么固态硬盘中安装系统安装 固态硬盘安装