学生信息管理系统

这是我自己弄的一个学生信息系统的小程序,用java弄!很简单

/*
 * student.java
 *
 * Created on 2007年11月15日, 下午4:25
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package 学信息管理系统;
import java.awt.*;
import java.awt.event.*;
import javax.swing.Box;
import java.lang.String;
import java.io.*;
import java.util.Date;
import javax.swing.JOptionPane;
class test extends Frame implements ActionListener,ItemListener
{
    TextField text1;
    TextField text2;
    Label label1,label2,label3;
    Box box1,box2,box3,boxbase;
    Checkbox checkbox1,checkbox2;
    FileDialog filedialog_save,filedialog_load;
    TextArea textarea;
    Button add,clear,save,open;
    CheckboxGroup sex;
    Choice choice1,choice2;
    FileWriter tofile;
    FileReader file_reader;
    BufferedReader in;
    BufferedWriter out;
    Date nowTime;
    test(String s)
    {
        super(s);
        add=new Button("添加");
        clear=new Button("清屏");
        open=new Button("打开文件");
        save=new Button("保存");
        text1=new TextField(10);
        text2=new TextField(18);
        textarea= new TextArea();
        textarea.setEditable(false);
        label1=new Label("输入编号");
        label2= new Label("输入姓名");
        box1=Box.createVerticalBox();
        sex=new CheckboxGroup();//CheckboxGroup()确定了每一个时刻职能有一个处于选中状态
        checkbox1=new Checkbox("男",true,sex);//true表示初始选中的状态
        checkbox2=new Checkbox("女",false,sex);
        choice1=new Choice();
        choice2=new Choice();
        choice1.add("经济管理学院");
        choice1.add("理学院");
        choice1.add("计算机科学与技术学院");
        choice1.add("人文学院");
        choice2.add("工商管理");
        save.addActionListener(this);
        open.addActionListener(this);
        clear.addActionListener(this);
        add.addActionListener(this);
        box1.add(label1);
        box1.add(Box.createHorizontalStrut(5));
        box1.add(text1);               
        box1.add(Box.createHorizontalStrut(5));
        box1.add(checkbox1);
        box1.add(Box.createHorizontalStrut(5));
        box1.add(choice1);
        box1.add(Box.createHorizontalStrut(5));
        box1.add(add);
        box1.add(Box.createHorizontalStrut(5));
        box1.add(open);
        box2=Box.createVerticalBox();
        box2.add(label2);
        box2.add(Box.createHorizontalStrut(5));
        box2.add(text2);
        box2.add(Box.createHorizontalStrut(5));
        box2.add(checkbox2);
        box2.add(Box.createHorizontalStrut(5));
        box2.add(choice2);
        box2.add(Box.createHorizontalStrut(5));
        box2.add(save);
        box2.add(Box.createHorizontalStrut(5));
        box2.add(clear);
        boxbase=Box.createHorizontalBox();
        boxbase.add(textarea);
        boxbase.add(box1);
        boxbase.add(Box.createHorizontalStrut(10));
        boxbase.add(box2);       
        setLayout(new FlowLayout());
        add(boxbase);
        setBounds(200,200,400,400);
        setVisible(true);
        validate();
        filedialog_save=new FileDialog(this,"保存文件对话框",FileDialog.SAVE);
        filedialog_save.addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                filedialog_save.setVisible(false);
            }
        });
        filedialog_load=new FileDialog(this,"打开文件对话框",FileDialog.LOAD);
        filedialog_load.addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                filedialog_load.setVisible(false);
            }
        } );
        addWindowListener(new WindowAdapter()
       {
          public void windowClosing(WindowEvent e)
          {
              System.exit(0);
          }
       });
    }
       public void actionPerformed(ActionEvent e)
       {
           if(e.getSource()==open)
           {
               filedialog_load.setVisible(true);
               textarea.setText(null);
               String s;
               if(filedialog_load.getFile()!=null)
               {
                   try{
                       File file= new File(filedialog_load.getDirectory(),filedialog_load.getFile());
                       file_reader=new FileReader(file);
                       in = new BufferedReader(file_reader);
                       while((s=in.readLine())!=null)
                           textarea.append(s+'/n');
                       in.close();
                       file_reader.close();
                   }
                   catch(IOException e2){}
               }
           }
           if(e.getSource()==save)
           {
                filedialog_save.setVisible(true);
                if( filedialog_save.getFile()!=null)
                {
                    try{
                        File file= new File( filedialog_save.getDirectory(), filedialog_save.getFile());
                        tofile=new FileWriter(file);
                        out=new BufferedWriter(tofile);
                        out.write(textarea.getText(),0,(textarea.getText()).length());
                        out.close();
                        tofile.close();
                    }
                      catch(IOException e2){}
                }
           }
       }

    public void itemStateChanged(ItemEvent e) {
    }
}
public void student
{
    public static void main(String args[])

{

    new test("输入学生信息的窗口");
                

  } 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值