高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(五)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(一)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(二)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(三)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(四)

[高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(五)](当前位置)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(六)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(七)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(八)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(九)

更多项目逐句吐血精讲在这里,加油ヾ(◍°∇°◍)ノ゙!!

项目效果图

功能点实现

  1. 实现学生信息的录入
  2. 实现学生信息的修改
  3. 实现学生信息的更新
  4. 实现学生信息的删除
  5. 添加快捷键使用,方便快速管理
  6. 使用javafx+fxml+css控制ui样式
  7. 实现以javafx内部api调用绘制字体特效,无需额外资源调度
  8. 实现软件图标自定义,增加软件美观度
  9. 实现拖动窗口即可移动,使更加人性化
  10. 实现软件英文化,增加可交流性
  11. 禁用窗口缩放功能,防止ui碰撞
  12. 添加作者、主页、关闭按钮
  13. 增加事务弹窗,给予正确提示及错误解决方案

内部优化

  1. 使用分装思想,将功能块拆分,设立CreateMenu类,统一添加
  2. 封装错误与信息提示框,统一布局格式
  3. 封装数据库连接类,无需重复调度
  4. 采用Lambda表达式绑定事件,无需重写类
  5. 使用fxml模块化设计标签,方便增改
  6. 采用css设置样式,统一管理
  7. 去除不必要的类public,增加软件安全性
  8. 利用SceneBuilder绘制生成fxml控件,提升编写效率
  9. 采用不同尺寸图标格式适应多种运行状态

类结构示例

在这里插入图片描述

创建其他的面板

1、创建DeleteFxml.fxml面板

在这里插入图片描述
和上一章前面的一样,就是把字改一下就行了

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

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<GridPane xmlns:fx="http://javafx.com/fxml" alignment="center" fx:controller="system.Delete"
          hgap="10" vgap="10">
    <padding>
        <Insets top="25" right="25" bottom="10" left="25" />
    </padding>

    <Label text="Welcome to Delete:" GridPane.columnSpan="2" stylesheets="/source/Title.css"
           GridPane.rowIndex="0" />


    <Label text="Please Input Delete Student Number:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="2" />
    <TextField fx:id="Number" GridPane.columnIndex="1" GridPane.rowIndex="2" />
    <HBox spacing="10" alignment="bottom_right" GridPane.columnIndex="3" GridPane.rowIndex="2">
        <Button text="Search" onAction="#SearchButtonAction" stylesheets="/source/Title.css" styleClass="btn"/>
    </HBox>

    <Label text="Student Name:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="3" />
    <TextField fx:id="Name" GridPane.columnIndex="1" GridPane.rowIndex="3" />

    <Label text="Student Gender:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="4" />
    <TextField fx:id="Gender" GridPane.columnIndex="1" GridPane.rowIndex="4" />

    <Label text="Student Address:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="5" />
    <TextField fx:id="Address" GridPane.columnIndex="1" GridPane.rowIndex="5" />

    <Label text="Student Phone:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="6" />
    <TextField fx:id="Phone" GridPane.columnIndex="1" GridPane.rowIndex="6" />

    <Label text="Student Major:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="7" />
    <TextField fx:id="Major" GridPane.columnIndex="1" GridPane.rowIndex="7" />


    <HBox spacing="10" alignment="center" GridPane.columnSpan="3" GridPane.rowIndex="10">
        <Button text="Delete" onAction="#DeleteButtonAction" stylesheets="/source/Title.css" styleClass="btn"/>
    </HBox>

</GridPane>

package system;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TextField;

import java.io.IOException;


public class Delete {

	@FXML
	TextField Number;
	@FXML
	TextField Name;
	@FXML
	TextField Gender;
	@FXML
	TextField Address;
	@FXML
	TextField Phone;
	@FXML
	TextField Major;

	@FXML
	void SearchButtonAction(ActionEvent event) {
	
	}
		
	@FXML
	void DeleteButtonAction(ActionEvent event) {
		
	}
	
	Parent createNode() throws IOException {
		return FXMLLoader.load(getClass().getResource("../source/DeleteFxml.fxml"));
	}
}

2、创建SearchFxml.fxml面板

在这里插入图片描述

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

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<GridPane xmlns:fx="http://javafx.com/fxml" alignment="center" fx:controller="system.Search"
          hgap="10" vgap="10">
    <padding>
        <Insets top="25" right="25" bottom="10" left="25" />
    </padding>

    <Label text="Welcome to Search:" GridPane.columnSpan="2" stylesheets="/source/Title.css"
           GridPane.rowIndex="0" />


    <Label text="Please Input Search Student Number:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="2" />
    <TextField fx:id="Number" GridPane.columnIndex="1" GridPane.rowIndex="2" />
    <HBox spacing="10" alignment="bottom_right" GridPane.columnIndex="3" GridPane.rowIndex="2">
        <Button text="Search" onAction="#SearchButtonAction" stylesheets="/source/Title.css" styleClass="btn"/>
    </HBox>

    <Label text="Student Name:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="3" />
    <TextField fx:id="Name" GridPane.columnIndex="1" GridPane.rowIndex="3" />

    <Label text="Student Gender:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="4" />
    <TextField fx:id="Gender" GridPane.columnIndex="1" GridPane.rowIndex="4" />

    <Label text="Student Address:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="5" />
    <TextField fx:id="Address" GridPane.columnIndex="1" GridPane.rowIndex="5" />

    <Label text="Student Phone:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="6" />
    <TextField fx:id="Phone" GridPane.columnIndex="1" GridPane.rowIndex="6" />

    <Label text="Student Major:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="7" />
    <TextField fx:id="Major" GridPane.columnIndex="1" GridPane.rowIndex="7" />

</GridPane>


package system;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.control.TextField;

import java.io.IOException;

public class Search {
    @FXML
    TextField Number;
    @FXML
    TextField Name;
    @FXML
    TextField Gender;
    @FXML
    TextField Address;
    @FXML
    TextField Phone;
    @FXML
    TextField Major;
    @FXML
    void SearchButtonAction(ActionEvent event) {
    
    }

    Parent createNode() throws IOException {
        return FXMLLoader.load(getClass().getResource("../source/SearchFxml.fxml"));
    }
}


3、创建UpdateFxml.fxml面板

在这里插入图片描述

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

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<GridPane xmlns:fx="http://javafx.com/fxml" alignment="center" fx:controller="system.Update"
          hgap="10" vgap="10">
    <padding>
        <Insets top="25" right="25" bottom="10" left="25"/>
    </padding>

    <Label text="Welcome to Update:" GridPane.columnSpan="2" stylesheets="/source/Title.css"
           GridPane.rowIndex="0"/>


    <Label text="Please Input Search Student Number:" GridPane.columnIndex="0" stylesheets="/source/Title.css"
           styleClass="label-oth" GridPane.rowIndex="2"/>
    <TextField fx:id="Number" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
    <HBox spacing="10" alignment="bottom_right" GridPane.columnIndex="3" GridPane.rowIndex="2">
        <Button text="Search" onAction="#SearchButtonAction" stylesheets="/source/Title.css" styleClass="btn"/>
    </HBox>

    <Label text="Student Name:" GridPane.columnIndex="0" GridPane.rowIndex="3" stylesheets="/source/Title.css"
           styleClass="label-oth"/>
    <TextField fx:id="Name" GridPane.columnIndex="1" GridPane.rowIndex="3"/>

    <Label text="Student Gender:" GridPane.columnIndex="0" GridPane.rowIndex="4" stylesheets="/source/Title.css"
           styleClass="label-oth"/>
    <TextField fx:id="Gender" GridPane.columnIndex="1" GridPane.rowIndex="4"/>

    <Label text="Student Address:" GridPane.columnIndex="0" GridPane.rowIndex="5" stylesheets="/source/Title.css"
           styleClass="label-oth"/>
    <TextField fx:id="Address" GridPane.columnIndex="1" GridPane.rowIndex="5"/>

    <Label text="Student Phone:" GridPane.columnIndex="0" GridPane.rowIndex="6" stylesheets="/source/Title.css"
           styleClass="label-oth"/>
    <TextField fx:id="Phone" GridPane.columnIndex="1" GridPane.rowIndex="6"/>

    <Label text="Student Major:" GridPane.columnIndex="0" GridPane.rowIndex="7" stylesheets="/source/Title.css"
           styleClass="label-oth"/>
    <TextField fx:id="Major" GridPane.columnIndex="1" GridPane.rowIndex="7"/>


    <HBox spacing="10" alignment="center" GridPane.columnSpan="3" GridPane.rowIndex="10">
        <Button text="Update" onAction="#UpdateButtonAction" stylesheets="/source/Title.css" styleClass="btn"/>
    </HBox>

</GridPane>

package system;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.control.TextField;

import java.io.IOException;

public class Update {
    @FXML
    TextField Number;
    @FXML
    TextField Name;
    @FXML
    TextField Gender;
    @FXML
    TextField Address;
    @FXML
    TextField Phone;
    @FXML
    TextField Major;

    @FXML
    void SearchButtonAction(ActionEvent event) {
        
    }

    @FXML
    void UpdateButtonAction(ActionEvent event) {
    
    }

    Parent createNode() throws IOException {
        return FXMLLoader.load(getClass().getResource("../source/UpdateFxml.fxml"));
    }
}


关注后续章节,我们会添加更多功能:

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(一)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(二)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(三)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(四)

[高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(五)](当前位置)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(六)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(七)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(八)

高颜值数据库项目实战MySQL+JavaFX+Fxml+CSS(完整精讲解版+源代码)(九)

后记

更多项目逐句吐血精讲在这里,加油ヾ(◍°∇°◍)ノ゙!!

C语言飞机大战小游戏(2万字!完整精讲解版+源代码)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值