Java课设--学生成绩管理系统七

本文详细介绍了Java课程设计中管理员界面的设计和功能实现,包括查询学生、教师,添加教师等操作。通过使用Scene Builder创建界面,并在Main函数中初始化页面,实现了界面与业务逻辑的结合。管理员可以查询并修改教师信息,但无法修改学生信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

写在前面

上一节介绍了学生界面的开发,这一节介绍管理员界面的设计,因为业务逻辑差不多,就简单的叙述了。

一、管理员主界面
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.image.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane prefHeight="600.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="studentSystem.controller.admin.AdminMainController">
    <children>
        <MenuBar layoutY="-2.0" prefHeight="35.0" prefWidth="1000.0">
            <menus>
                <Menu mnemonicParsing="false" text="查询">
                    <items>
                        <MenuItem fx:id="queryAllStudent" onAction="#queryAllStudentEvent" mnemonicParsing="false" text="查询所有学生" />
                        <MenuItem fx:id="queryAllTeacher" onAction="#queryAllTeacherEvent" mnemonicParsing="false" text="查询所有教师" />
                    </items>
                </Menu>
                <Menu mnemonicParsing="false" text="添加用户">
                    <items>
                        <MenuItem fx:id="addTeacher" onAction="#addTeacherEvent" mnemonicParsing="false" text="添加教师" />
                    </items>
                </Menu>
                <Menu mnemonicParsing="false" text="个人中心">
                    <items>
                        <!--<MenuItem fx:id="queryAdminInfo" onAction="#queryAdminInfoEvent" mnemonicParsing="false" text="查看个人信息" />-->
                        <MenuItem fx:id="exitSys" onAction="#exitSystem" mnemonicParsing="false" text="退出系统" />
                    </items>
                </Menu>
                <Menu mnemonicParsing="false" text="关于">
                    <items>
                        <MenuItem fx:id="showDesc" mnemonicParsing="false" text="简介" />
                        <MenuItem fx:id="callUs" mnemonicParsing="false" text="联系我们" />
                    </items>
                </Menu>
            </menus>
        </MenuBar>
      <AnchorPane fx:id="mainFrameAnchorPane" layoutY="33.0" prefHeight="565.0" prefWidth="1000.0">
         <children>
            <HBox prefHeight="565.0" prefWidth="1000.0" alignment="CENTER">
               <children>
                  <ImageView fx:id="backgroundView" fitHeight="565.0" fitWidth="1000.0" pickOnBounds="true" preserveRatio="true" />
               </children>
            </HBox>
         </children>
      </AnchorPane>
    </children>
</AnchorPane>

package studentSystem.controller.admin;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.MenuItem;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import studentSystem.Main;
import studentSystem.utils.SimpleTools;

import java.io.IOException;

/**
 * @author D.hu
 * @date 2020/12/6
 * @desc
 */
public class AdminMainController {
   

    private SimpleTools simpleTools = new SimpleTools();

    @FXML
    private MenuItem queryAllTeacher;

    @FXML
    private AnchorPane mainFrameAnchorPane;

    @FXML
    private MenuItem queryAllStudent;

    @FXML
    private ImageView backgroundView;

    @FXML
    private MenuItem addTeacher;

    @FXML
    private MenuItem exitSys;

    @FXML
    private MenuItem callUs;

    @FXML
    private MenuItem showDesc;

    public void initialize() {
   
        MenuItem[] labeleds = {
   queryAllStudent, queryAllTeacher, addTeacher, exitSys, callUs, showDesc};
        String[] imagePaths = {
   "src/studentSystem/images/fly1.png", "src/studentSystem/images/fly2.png",
                "src/studentSystem/images/add1.png", "src/studentSystem/images/logout.png","src/studentSystem/images/phone2.png", "src/studentSystem/images/desc.png"};
        simpleTools.setMenuItemImage(labeleds, imagePaths);
        // 设置图片
        backgroundView.setImage(new Image("file:src/studentSystem/images/bg2.png"));
    }

    public void queryAllStudentEvent(ActionEvent actionEvent) throws IOException {
   
        AnchorPane pane = new Main().initQueryAllStudentFrame();
        mainFrameAnchorPane.getChildren().clear();
        mainFrameAnchorPane.getChildren().add(pane);
    }

    public void queryAllTeacherEvent(ActionEvent actionEvent) throws IOException {
   
        AnchorPane pane = new Main().initQueryAllTeacherFrame();
        mainFrameAnchorPane.getChildren().clear();
        mainFrameAnchorPane.getChildren().add(pane);
    }

    public void addTeacherEvent(ActionEvent actionEvent) throws IOException {
   
        AnchorPane pane = new Main().initAddTeacherFrame();
        mainFrameAnchorPane.getChildren().clear();
        mainFrameAnchorPane.getChildren().add(pane);
    }

    public void exitSystem(ActionEvent actionEvent) {
   
        System.exit(0);
    }

}

二、查询学生

查询学生管理员只需要知道学生的信息就好了,不需要对于学生进行修改。修改的业务就直接交给教师。
在这里插入图片描述
这个是界面的截图,主要元素就是表格、标签、文本框、按钮。这些都是自己使用scene builder自动生成的。代码如下:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane prefHeight="565.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="studentSystem.controller.admin.QueryAllStudentController">
    <children>
        <VBox prefHeight="565.0" prefWidth="1000.0">
            <children>
                <HBox alignment="CENTER" prefHeight="68.0" prefWidth="1000.0">
                    <children>
                        <Label fx:id="infoLabel" prefHeight="47.0" prefWidth="357.0" text="  学  生  信  息">
                            <font>
                                <Font name="System Bold" size="28.0" />
                            </font>
                        </Label>
                    </children>
                </HBox>
                <HBox alignment="CENTER" prefHeight="50.0" prefWidth="1000.0">
                    <children>
                        <Label fx:id="queryNameLabel" prefHeight="20.0" prefWidth="70.0" text="姓名:" />
                        <TextField fx:id="inputName" prefHeight="30.0" prefWidth="99.0" />
                        <Label fx:id="queryStudentNumLabel" prefHeight="20.0" prefWidth="70.0" text="学号:">
                            <HBox.margin>
                                <Insets left="20.0" />
                            </HBox.margin>
                        </Label>
                        <TextField fx:id="inputStudentNum" prefHeight="30.0" prefWidth="123.0" />
                        <Button fx:id="queryButton" mnemonicParsing="false" onAction="#queryStudent" prefHeight="30.0" prefWidth="100.0" text="查询">
                            <HBox.margin>
                                <Insets left="20.0" />
                            </HBox.margin>
                        </Button>
                        <Button fx:id="resetQueryButton" mnemonicParsing="false" onAction="#reset" prefHeight="30.0" prefWidth="100.0" text="重置">
                            <HBox.margin>
                                <Insets left="20.0" />
                            </HBox.margin>
                        </Button>
                    </children>
                </HBox>
                <HBox alignment="CENTER" prefHeight="446.0" prefWidth="1000.0">
                    <children>
                        <TableView fx:id="studentTableView" prefHeight="446.0" prefWidth="638.0">
                            <columns>
                                <TableColumn fx:id="studentNumTableColumn" prefWidth="120.0" text="学号" />
                                <TableColumn fx:id="usernameTableColumn" prefWidth="90.0" text="用户名" />
                                <TableColumn fx:id
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值