1.登录界面

其中的图片存储路径可以替换成自己的,当然我这里的账号密码是先设置好的,其实可以做一个注册的功能,把账号密码存进文件中

package SchoolWork.ManagementSystem;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
import javafx.stage.Stage;

public class Login extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        Pane pane = new Pane();

        Image image = new Image("SchoolWork/ManagementSystem/Login.jpg");
        ImageView imageView = new ImageView(image);
        imageView.setFitHeight(500);
        imageView.setFitWidth(900);

        pane.getChildren().add(imageView);

        Label label1 = new Label("账号:");
        Label label2 = new Label("密码:");
        Font font = new Font(16);
        label1.setFont(font);
        label1.setLayoutX(40);
        label1.setLayoutY(100);
        label2.setFont(font);
        label2.setLayoutX(40);
        label2.setLayoutY(160);

        TextField t1 = new TextField();
        PasswordField t2 = new PasswordField();
        t1.setLayoutX(85);
        t1.setLayoutY(100);
        t2.setLayoutX(85);
        t2.setLayoutY(160);

        Button b1 = new Button("登入");
        b1.setLayoutX(80);
        b1.setLayoutY(290);

        b1.setOnAction(event -> {
            if(t1.getText().equals("1515477256") && t2.getText().equals("1515477256zyh")){
                primaryStage.hide();
                Main main = new Main();
                try {
                    main.start(new Stage());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            } else{
                LoginError loginError = new LoginError();
                try {
                    loginError.start(new Stage());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }

            }
        });

        Button b2 = new Button("登出");
        b2.setLayoutX(180);
        b2.setLayoutY(290);
        b2.setOnAction(event -> {
            primaryStage.hide();
        });

        pane.getChildren().addAll(label1,label2,b1,t1,t2,b2);

        Scene scene = new Scene(pane, 300, 350);

        primaryStage.setScene(scene);
        primaryStage.setTitle("登入");
        primaryStage.setResizable(false);
        primaryStage.getIcons().add(new Image("SchoolWork/ManagementSystem/Ego_KaKa.jpg"));
        primaryStage.show();
    }
}

 2.当然要考虑到账号密码错误的情况

package SchoolWork.ManagementSystem;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

public class LoginError extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        Pane pane = new Pane();

        Label label = new Label("账号或密码错误");
        label.setTextFill(Color.RED);
        label.setLayoutY(40);
        label.setLayoutX(90);
        pane.getChildren().add(label);

        Button button = new Button("重新输入");
        button.setLayoutY(90);
        button.setLayoutX(100);
        button.setOnAction(event -> {
            primaryStage.hide();
        });

        pane.getChildren().add(button);

        Scene scene = new Scene(pane, 250, 150);

        primaryStage.setTitle("登入失败");
        primaryStage.show();
        primaryStage.setScene(scene);
        primaryStage.getIcons().add(new Image("SchoolWork/ManagementSystem/Ego_KaKa.jpg"));
        primaryStage.centerOnScreen();
    }
}

3.主界面

同样的,图片路径都可以换成自己的,需要注意的是因为这个主界面按钮个数比较多,所以我单独建了一个类

package SchoolWork.ManagementSystem;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
import javafx.stage.Stage;

public class Main extends Application {

    public static void main(String[] args) {
        Application.launch();
    }

    public void start(Stage primaryStage) throws Exception {
        Pane pane = new Pane();



        BT bt = new BT();
        bt.button(primaryStage);

        Label label1 = new Label("学生成绩管理系统");
        Font font = new Font(25);
        label1.setLayoutX(350);
        label1.setLayoutY(50);
        label1.setFont(font);

        Image image2 = new Image("SchoolWork/ManagementSystem/欢迎使用.png");
        ImageView imageView2 = new ImageView(image2);
        imageView2.setFitHeight(500);
        imageView2.setFitWidth(900);

        pane.getChildren().add(imageView2);

        pane.getChildren().addAll(label1,bt);

        Scene scene = new Scene(pane, 900, 500);

        primaryStage.setTitle("学生信息管理系统");
        primaryStage.setScene(scene);
        primaryStage.setResizable(false);
        primaryStage.getIcons().add(new Image("SchoolWork/ManagementSystem/Ego_KaKa.jpg"));
        primaryStage.show();
    }
}
package SchoolWork.ManagementSystem;

import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class BT extends Pane {

    public void button(Stage pri){
        Button button1 = new Button("输入信息");
        button1.setLayoutX(400);
        button1.setLayoutY(100);
        button1.setMinWidth(100);
        button1.setMinHeight(30);
        Button button2 = new Button("查找信息");
        button2.setLayoutX(400);
        button2.setLayoutY(150);
        button2.setMinWidth(100);
        button2.setMinHeight(30);
        Button button5 = new Button("查看全部");
        button5.setLayoutX(400);
        button5.setLayoutY(330);
        button5.setMinWidth(100);
        button5.setMinHeight(30);
        Button button6 = new Button("退出");
        button6.setLayoutX(400);
        button6.setLayoutY(380);
        button6.setMinWidth(100);
        button6.setMinHeight(30);

        getChildren().addAll(button1,button2,button5,button6);

        button1.setOnAction(event -> {
            Input input = new Input();
            try {
                input.start(new Stage());
                pri.hide();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
        button2.setOnAction(event -> {
            Seek seek = new Seek();
            try {
                seek.start(new Stage());
                pri.hide();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });

        button6.setOnAction(event -> {
            pri.hide();
            Login login = new Login();
            try {
                login.start(new Stage());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });

        button5.setOnAction(event -> {
            allStudent allStudent = new allStudent();
            try {
                allStudent.start(new Stage());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });

    }
}

4.展示所有学生的界面

tableview控件可以方便的实现排序并且展示效果也更好

package SchoolWork.ManagementSystem;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.stage.Stage;

import java.io.*;
import java.util.ArrayList;

public class allStudent extends Application {
    ObservableList data = FXCollections.observableArrayList();
    TableView<Student> tabableView = new TableView();

    @Override
    public void start(Stage primaryStage) throws Exception {

        Group group = new Group();

        Scene scene = new Scene(group,750,450);
        tabableView.setPrefHeight(450);
        tabableView.setPrefWidth(750);

        TableColumn name = new TableColumn<>("姓名");
        name.setCellValueFactory(new PropertyValueFactory<Student,String>("name"));
        name.setPrefWidth(100);
        tabableView.getColumns().add(name);

        TableColumn number = new TableColumn<>("学号");
        number.setCellValueFactory(new PropertyValueFactory<Student,String>("Number"));
        number.setPrefWidth(110);
        tabableView.getColumns().add(number);

        TableColumn gender = new TableColumn<>("性别");
        gender.setCellValueFactory(new PropertyValueFactory<Student,String>("gender"));
        gender.setPrefWidth(50);
        tabableView.getColumns().add(gender);

        TableColumn clasz = new TableColumn<>("班级");
        clasz.setCellValueFactory(new PropertyValueFactory<Student,String>("Clasz"));
        clasz.setPrefWidth(150);
        tabableView.getColumns().add(clasz);

        TableColumn id = new TableColumn<>("身份证");
        id.setCellValueFactory(new PropertyValueFactory<Student,String>("ID"));
        id.setPrefWidth(200);
        tabableView.getColumns().add(id);

        TableColumn bothday = new TableColumn<>("出生日期");
        bothday.setCellValueFactory(new PropertyValueFactory<Student,String>("bothDay"));
        bothday.setPrefWidth(150);
        tabableView.getColumns().add(bothday);


        File file = new File("学生信息表");
        FileInputStream fint = null;
        ObjectInputStream oint = null;

        try {
            fint = new FileInputStream(file);
            oint = new ObjectInputStream(fint);

            Object o = oint.readObject();
            if (o instanceof ArrayList) {
                ArrayList<Student> array = (ArrayList<Student>) o;
                data = FXCollections.observableArrayList(array);
            }
        } catch (EOFException ignored) {
        }  finally {
            try {
                if (oint != null) {
                    oint.close();
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }



        tabableView.setItems(data);
        ((Group)scene.getRoot()).getChildren().add(tabableView);
        primaryStage.show();
        primaryStage.setScene(scene);
        primaryStage.setResizable(false);
        primaryStage.setTitle("所有学生");
        primaryStage.centerOnScreen();
        primaryStage.getIcons().add(new Image("SchoolWork/ManagementSystem/Ego_KaKa.jpg"));
    }
}

5.录入学生信息

package SchoolWork.ManagementSystem;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
import javafx.stage.Stage;

import java.io.*;
import java.util.ArrayList;

public class Input extends Application {

    static ArrayList<Student> arrayList = new ArrayList<>();

    @Override
    public void start(Stage primaryStage) throws Exception {

        TextField[] textField = new TextField[5];

        for (int i = 0; i < 5; i++) {
            textField[i] = new TextField();
            textField[i].setLayoutX(400);
            textField[i].setLayoutY(150 + i * 50);
            textField[i].setEditable(true);
        }
        textField[2].setPromptText("XXXX-XX-XX");


        Pane pane = new Pane();

        Image image = new Image("SchoolWork/ManagementSystem/allstudent.jpg");
        ImageView imageView = new ImageView(image);
        imageView.setFitHeight(500);
        imageView.setFitWidth(900);

        pane.getChildren().add(imageView);

        Label label1 = new Label("          学生信息");
        Font font = new Font(25);
        label1.setLayoutX(350);
        label1.setLayoutY(70);
        label1.setFont(font);
        Label label2 = new Label("姓名 :");
        label2.setLayoutX(340);
        label2.setLayoutY(150);
        Label label3 = new Label("身份证 :");
        label3.setLayoutX(340);
        label3.setLayoutY(200);
        Label label4 = new Label("出生日期 :");
        label4.setLayoutX(340);
        label4.setLayoutY(250);
        Label label5 = new Label("学号 :");
        label5.setLayoutX(340);
        label5.setLayoutY(300);
        Label label6 = new Label("班级 :");
        label6.setLayoutX(340);
        label6.setLayoutY(350);
        Label label7 = new Label("联系电话 :");
        label7.setLayoutX(340);
        label7.setLayoutY(400);

        Button button8 = new Button("主菜单");
        button8.setLayoutX(830);
        button8.setLayoutY(480);
        button8.setMinWidth(70);
        button8.setMinHeight(20);

        RadioButton b1 = new RadioButton("男");
        b1.setLayoutY(400);
        b1.setLayoutX(410);


        RadioButton b2 = new RadioButton("女");
        b2.setLayoutY(400);
        b2.setLayoutX(510);

        ToggleGroup group = new ToggleGroup();
        b1.setToggleGroup(group);
        b1.setSelected(true);
        b2.setToggleGroup(group);

        Button button9 = new Button("确定");
        button9.setLayoutY(470);
        button9.setLayoutX(420);
        button9.setMinWidth(100);
        button9.setMinHeight(30);
        button9.setOnAction(event -> {

            if(textField[1].getText().length() == 18 && textField[2].getText().length() == 10) {

                Student st = new Student();

                st.setClasz(textField[4].getText());
                st.setName(textField[0].getText());
                st.setNumber(textField[3].getText());
                st.setID(textField[1].getText());
                st.setBothDay(textField[2].getText());
                if (b1.isSelected()) {
                    st.setGender("男");
                } else if (b2.isSelected()) {
                    st.setGender("女");
                }
//          st.setPhoneNumber(label7.getText());

                File file = new File("学生信息表");
                if (!file.exists()) {
                    try {
                        file.createNewFile();
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
                FileOutputStream foot = null;
                ObjectOutputStream oot = null;
                FileInputStream fint = null;
                ObjectInputStream oint = null;
                try {
                    fint = new FileInputStream(file);
                    if (fint.available() == 0) {
                        foot = new FileOutputStream(file);
                        oot = new ObjectOutputStream(foot);
                        arrayList.add(st);
                        Main main = new Main();
                        oot.writeObject(arrayList);
                        main.start(new Stage());
                        primaryStage.hide();
                    } else {
                        oint = new ObjectInputStream(fint);
                        Object o = oint.readObject();
                        if (o instanceof ArrayList) {
                            ((ArrayList<Student>) o).add(st);
                            foot = new FileOutputStream(file);
                            oot = new ObjectOutputStream(foot);
                            oot.writeObject(o);
                            Main main = new Main();
                            main.start(new Stage());
                            primaryStage.hide();
                        }
                    }
                } catch (Exception e) {
                    throw new RuntimeException(e);
                } finally {
                    try {
                        if (oint != null) {
                            oint.close();
                        }
                        if (oot != null) {
                            oot.close();
                        }
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            }else{
                Error error = new Error();
                try {
                    error.start(new Stage());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

        });

        button8.setOnAction(event -> {
            Main main = new Main();
            try {
                main.start(new Stage());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            primaryStage.hide();
        });


        for (int i = 0;i < 5;i++) {
            pane.getChildren().add(textField[i]);
        }



        pane.getChildren().addAll(label1,label2,label3,label4,
                                  label5,label6, button8,button9,b1,b2);

        Scene scene = new Scene(pane, 900, 500);


        primaryStage.setTitle("学生信息管理系统");
        primaryStage.setScene(scene);
        primaryStage.getIcons().add(new Image("SchoolWork/ManagementSystem/Ego_KaKa.jpg"));
        primaryStage.setResizable(false);
        primaryStage.show();
    }

}

8.查找学生信息

package SchoolWork.ManagementSystem;


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
import javafx.stage.Stage;

import java.io.*;
import java.util.ArrayList;

public class Seek extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        Pane pane = new Pane();

        Image image = new Image("SchoolWork/ManagementSystem/Seek.jpg");
        ImageView imageView = new ImageView(image);
        imageView.setFitHeight(500);
        imageView.setFitWidth(900);

        pane.getChildren().add(imageView);

        Label label1 = new Label("输入目标学生");
        Font font = new Font(25);
        label1.setLayoutX(400);
        label1.setLayoutY(70);
        label1.setFont(font);
        Label label2 = new Label("信息 :");
        label2.setLayoutX(340);
        label2.setLayoutY(205);
        TextField textField = new TextField();
        textField.setLayoutX(400);
        textField.setLayoutY(200);
        Button b1 = new Button("根据学号查询");
        b1.setLayoutX(430);
        b1.setLayoutY(300);
        Button b2 = new Button("根据姓名查询");
        b2.setLayoutX(430);
        b2.setLayoutY(340);
        Button b3 = new Button("根据班级统计");
        b3.setLayoutX(430);
        b3.setLayoutY(380);
        Button button = new Button("主菜单");
        button.setLayoutX(830);
        button.setLayoutY(480);
        button.setMinWidth(70);
        button.setMinHeight(20);

        b1.setOnAction(event -> {
            File file = new File("学生信息表");
            FileInputStream fint = null;
            ObjectInputStream oint = null;
            try {
                fint = new FileInputStream(file);
                oint = new ObjectInputStream(fint);

                Object o = oint.readObject();
                String text = textField.getText();
                if (o instanceof ArrayList) {
                    for (int i = 0; i < ((ArrayList<?>) o).size(); i++) {
                        Student student = (Student) ((ArrayList<?>) o).get(i);
                        if (text.equals(student.getNumber())) {
                            primaryStage.hide();
                            seek(student);
                            break;
                        }
                    }
                }
                textField.setText("无");
            } catch (EOFException ignored) {
                textField.setText("无数据");
            } catch (IOException | ClassNotFoundException e) {
                throw new RuntimeException(e);
            } finally {
                try {
                    if (oint != null) {
                        oint.close();
                    }
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        b2.setOnAction(event -> {
            File file = new File("学生信息表");
            FileInputStream fint = null;
            ObjectInputStream oint = null;
            try {
                fint = new FileInputStream(file);
                oint = new ObjectInputStream(fint);

                Object o = oint.readObject();
                String text = textField.getText();
                if (o instanceof ArrayList) {
                    for (int i = 0; i < ((ArrayList<?>) o).size(); i++) {
                        Student student = (Student) ((ArrayList<?>) o).get(i);
                        if (text.equals(student.getName())) {
                            primaryStage.hide();
                            seek(student);
                            break;
                        }
                    }
                }
                textField.setText("无");
            } catch (EOFException ignored) {
                textField.setText("无数据");
            } catch (IOException | ClassNotFoundException e) {
                throw new RuntimeException(e);
            } finally {
                try {
                    if (oint != null) {
                        oint.close();
                    }
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        b3.setOnAction(event -> {
            ArrayList<Student> arrayList = new ArrayList<>();
            File file = new File("学生信息表");
            FileInputStream fint = null;
            ObjectInputStream oint = null;
            try {
                fint = new FileInputStream(file);
                oint = new ObjectInputStream(fint);

                Object o = oint.readObject();
                String text = textField.getText();
                if (o instanceof ArrayList) {
                    for (int i = 0; i < ((ArrayList<?>) o).size(); i++) {
                        Student student = (Student) ((ArrayList<?>) o).get(i);
                        if (text.equals(student.getClasz())) {
                            arrayList.add(((ArrayList<Student>) o).get(i));
                        }
                    }
                    primaryStage.hide();
                    clasz(arrayList);
                }
                textField.setText("无");
            } catch (EOFException ignored) {
                textField.setText("无数据");
            } catch (IOException | ClassNotFoundException e) {
                throw new RuntimeException(e);
            } finally {
                try {
                    if (oint != null) {
                        oint.close();
                    }
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        button.setOnAction(event -> {
            Main main = new Main();
            try {
                main.start(new Stage());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            primaryStage.hide();
        });


        pane.getChildren().addAll(label1, label2, textField, b1, b2, b3,button);

        Scene scene = new Scene(pane, 900, 500);

        primaryStage.setTitle("学生信息管理系统");
        primaryStage.setScene(scene);
        primaryStage.setResizable(false);
        primaryStage.getIcons().add(new Image("SchoolWork/ManagementSystem/Ego_KaKa.jpg"));
        primaryStage.show();
    }

    public void seek(Student st) {
        SeekScene seekScene = new SeekScene(st);
        try {
            seekScene.start(new Stage());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
        public void clasz(ArrayList<Student> arrayList){
        Clasz clasz = new Clasz(arrayList);
        try {
            clasz.start(new Stage());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}

9.展示查找的学生信息

package SchoolWork.ManagementSystem;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
import javafx.stage.Stage;

import java.io.*;
import java.util.ArrayList;

public class SeekScene extends Application {

    private Student student;

    public SeekScene(Student student) {
        this.student = student;
    }


    @Override
    public void start(Stage primaryStage) throws Exception {

        TextField[] textField = new TextField[5];

        for (int i = 0; i < 5; i++) {
            textField[i] = new TextField();
            textField[i].setLayoutX(400);
            textField[i].setLayoutY(150 + i * 50);
            textField[i].setEditable(false);
        }
        textField[0].setText(student.getName());
        textField[1].setText(student.getID());
        textField[2].setText(student.getBothDay());
        textField[3].setText(student.getNumber());
        textField[4].setText(student.getClasz());

        Pane pane = new Pane();

        Image image = new Image("SchoolWork/ManagementSystem/Seek.jpg");
        ImageView imageView = new ImageView(image);
        imageView.setFitHeight(500);
        imageView.setFitWidth(900);

        pane.getChildren().add(imageView);

        Label label1 = new Label("          学生信息");
        Font font = new Font(25);
        label1.setLayoutX(350);
        label1.setLayoutY(70);
        label1.setFont(font);
        Label label2 = new Label("姓名 :");
        label2.setLayoutX(340);
        label2.setLayoutY(150);
        Label label3 = new Label("身份证 :");
        label3.setLayoutX(340);
        label3.setLayoutY(200);
        Label label4 = new Label("出生日期 :");
        label4.setLayoutX(340);
        label4.setLayoutY(250);
        Label label5 = new Label("学号 :");
        label5.setLayoutX(340);
        label5.setLayoutY(300);
        Label label6 = new Label("班级 :");
        label6.setLayoutX(340);
        label6.setLayoutY(350);
        Label label7 = new Label("联系电话 :");
        label7.setLayoutX(340);
        label7.setLayoutY(400);

        Button button8 = new Button("主菜单");
        button8.setLayoutX(830);
        button8.setLayoutY(480);
        button8.setMinWidth(70);
        button8.setMinHeight(20);
        button8.setOnAction(event -> {
            Main main = new Main();
            try {
                main.start(new Stage());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            primaryStage.hide();
        });
        RadioButton be = new RadioButton("修改");
        be.setSelected(false);
        be.setLayoutX(560);
        be.setLayoutY(480);
        be.setOnAction(event -> {
            for (int i = 0; i < 5; i++) {
                textField[i].setEditable(true);
            }
        });

        RadioButton b1 = new RadioButton("男");
        b1.setLayoutY(400);
        b1.setLayoutX(410);


        RadioButton b2 = new RadioButton("女");
        b2.setLayoutY(400);
        b2.setLayoutX(510);

        pane.getChildren().addAll(b1,b2);

        ToggleGroup group = new ToggleGroup();
        b1.setToggleGroup(group);
        b1.setSelected(true);
        b2.setToggleGroup(group);

        Button button1 = new Button("确认");
        button1.setLayoutY(470);
        button1.setLayoutX(360);
        button1.setMinWidth(90);
        button1.setMinHeight(30);
        button1.setOnAction(event -> {
            if(textField[1].getText().length() == 18 && textField[2].getText().length() == 10) {
                Student st1 = new Student();
                st1.setName(textField[0].getText());
                st1.setID(textField[1].getText());
                st1.setBothDay(textField[2].getText());
                st1.setNumber(textField[3].getText());
                st1.setClasz(textField[4].getText());
                if (b1.isSelected()) {
                    st1.setGender("男");
                } else if (b2.isSelected()) {
                    st1.setGender("女");
                }
                File file = new File("学生信息表");
                FileInputStream fint = null;
                ObjectInputStream oint = null;
                try {
                    fint = new FileInputStream(file);
                    oint = new ObjectInputStream(fint);
                    Object o = oint.readObject();
                    if (o instanceof ArrayList) {
                        for (int i = 0; i < ((ArrayList<?>) o).size(); i++) {
                            if (student.getNumber().equals(((ArrayList<Student>) o).get(i).getNumber())) {
                                ((ArrayList<?>) o).remove(i);
                                ((ArrayList<Student>) o).add(st1);
                                FileOutputStream foot = null;
                                ObjectOutputStream oot = null;
                                try {
                                    foot = new FileOutputStream(file);
                                    oot = new ObjectOutputStream(foot);
                                    oot.writeObject(o);
                                } catch (Exception e) {
                                    throw new RuntimeException(e);
                                } finally {
                                    try {
                                        if (oot != null) {
                                            oot.close();
                                        }
                                    } catch (IOException e) {
                                        throw new RuntimeException(e);
                                    }
                                }
                            }
                        }
                        Main main = new Main();
                        main.start(new Stage());
                        primaryStage.hide();
                    }
                } catch (Exception e) {
                    throw new RuntimeException(e);
                } finally {
                    try {
                        if (oint != null) {
                            oint.close();
                        }
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            }else{
                Error error = new Error();
                try {
                    error.start(new Stage());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        });


        Button button2 = new Button("删除");
        button2.setLayoutY(470);
        button2.setLayoutX(460);
        button2.setMinWidth(90);
        button2.setMinHeight(30);
        button2.setOnAction(event -> {
            Student st2 = new Student();
            st2.setName(textField[0].getText());
            st2.setID(textField[1].getText());
            st2.setBothDay(textField[2].getText());
            st2.setNumber(textField[3].getText());
            st2.setClasz(textField[4].getText());
            File file = new File("学生信息表");
            FileInputStream fint = null;
            ObjectInputStream oint = null;
            try {
                fint = new FileInputStream(file);
                oint = new ObjectInputStream(fint);
                Object o = oint.readObject();
                if (o instanceof ArrayList) {
                    for (int i = 0; i < ((ArrayList<?>) o).size(); i++) {
                        if(st2.getNumber().equals(((ArrayList<Student>) o).get(i).getNumber())){
                            ((ArrayList<?>) o).remove(i);
                            FileOutputStream foot = null;
                            ObjectOutputStream oot = null;
                            try {
                                foot = new FileOutputStream(file);
                                oot = new ObjectOutputStream(foot);
                                oot.writeObject(o);
                            } catch (Exception e) {
                                throw new RuntimeException(e);
                            } finally {
                                try {
                                    if (oot != null) {
                                        oot.close();
                                    }
                                } catch (IOException e) {
                                    throw new RuntimeException(e);
                                }
                            }
                        }
                    }
                    Main main = new Main();
                    main.start(new Stage());
                    primaryStage.hide();
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            } finally {
                try {
                    if (oint != null) {
                        oint.close();
                    }
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        for (int i = 0;i < 5;i++) {
            pane.getChildren().add(textField[i]);
        }

        pane.getChildren().addAll(label1,label2,label3,label4,
                label5,label6, button8,be,button1,button2);

        Scene scene = new Scene(pane, 900, 500);


        primaryStage.setTitle("学生信息管理系统");
        primaryStage.setScene(scene);
        primaryStage.setResizable(false);
        primaryStage.getIcons().add(new Image("SchoolWork/ManagementSystem/Ego_KaKa.jpg"));
        primaryStage.show();
    }
}

还有很多的功能就不一一列出来了,个人觉得对本身有很大的成就意义,毕竟都是自己一点一点写出来的,许多构思也是自己一点一点思考出来的,比上个学期用c语言写出的有很大的进步!!!

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

多的不唠,整个学生信息系统做下来其实没有很大的难度,毕竟功能也比较简单,感兴趣的同学可以点击链接 https://www.aliyundrive.com/s/FPuqQjPwY6p 提取码: 38kq 参考参考