结合 AI 使用 GUI 编程实现一个黑马人事管理系统

目录

案例要求

实现思路

代码

App启动类

Bean包

Employee实体类

User实体类

ui包

AddEmployeeUI

EmployeeManagerUI

LoginUI

RegisterUI

总结:


案例要求

实现思路

第一步:创建一个模块做这个项目。itheima - employee - sys
第二步:分析项目的业务需求。

  • 提供一个登录和注册用户的界面。
  • 提供一个人事信息的管理界面:展示全部员工信息,提供一个根据名称查询某个员工信息展示,添加员工信息,删除员工信息,修改员工信息。
  • 分析项目的角色:
    -- 登录用户:登录名称,密码。
    -- 员工信息:ID, 姓名,性别,年龄,电话,职位,入职时间,薪水,部门信息。

第三步:结合AI进行开发,使用ai生成gui界面

代码

App启动类

import com.itheima.ui.LoginUI;

public class App {
    public static void main(String[] args) {
         new LoginUI();
    }
}

Bean包

Employee实体类

package com.itheima.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

// 员工信息:"ID", "姓名", "性别", "年龄", "电话" ,"职位", "入职日期", "薪水", "部门"
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Employee {
    private int id;
    private String name;
    
    private String sex;
    private int age;
    private String phone;
    private String position;
    private String entryDate;
    private double salary;
    private String department;
}

User实体类

package com.itheima.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

// 用户信息包含用户名,密码,登录名。
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User {
    private String username; // 用户名
    private String password; // 密码
    private String loginName; // 登录名
}

ui包

AddEmployeeUI

package com.itheima.ui;

import com.itheima.bean.Employee;

import javax.swing.*;
import java.awt.*;
import java.text.SimpleDateFormat;

public class AddEmployeeUI extends JFrame {
    private JTextField txtId, txtName, txtSex, txtAge, txtPhone, txtPosition, txtSalary, txtDepartment;
    private JFormattedTextField txtHireDate;
    private JButton btnSave, btnCancel;
    private EmployeeManagerUI employeeManagerUI;

    public AddEmployeeUI(EmployeeManagerUI employeeManagerUI) {
        super("添加员工信息");
        this.employeeManagerUI = employeeManagerUI;
        setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 5, 5, 5);

        Font labelFont = new Font("楷体", Font.PLAIN, 14);

        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.EAST;
        JLabel idLabel = new JLabel("ID:");
        idLabel.setFont(labelFont);
        add(idLabel, gbc);

        gbc.gridx = 1;
        gbc.anchor = GridBagConstraints.WEST;
        txtId = new JTextField(10);
        add(txtId, gbc);

        gbc.gridx = 0;
        gbc.gridy = 1;
        JLabel nameLabel = new JLabel("姓名:");
        nameLabel.setFont(labelFont);
        add(nameLabel, gbc);

        gbc.gridx = 1;
        txtName = new JTextField(10);
        add(txtName, gbc);

        gbc.gridx = 0;
        gbc.gridy = 2;
        JLabel sexLabel = new JLabel("性别:");
        sexLabel.setFont(labelFont);
        add(sexLabel, gbc);

        gbc.gridx = 1;
        txtSex = new JTextField(10);
        add(txtSex, gbc);

        gbc.gridx = 0;
        gbc.gridy = 3;
        JLabel ageLabel = new JLabel("年龄:");
        ageLabel.setFont(labelFont);
        add(ageLabel, gbc);

        gbc.gridx = 1;
        txtAge = new JTextField(10);
        add(txtAge, gbc);

        gbc.gridx = 0;
        gbc.gridy = 4;
        JLabel phoneLabel = new JLabel("电话:");
        phoneLabel.setFont(labelFont);
        add(phoneLabel, gbc);

        gbc.gridx = 1;
        txtPhone = new JTextField(10);
        add(txtPhone, gbc);

        gbc.gridx = 0;
        gbc.gridy = 5;
        JLabel positionLabel = new JLabel("职位:");
        positionLabel.setFont(labelFont);
        add(positionLabel, gbc);

        gbc.gridx = 1;
        txtPosition = new JTextField(10);
        add(txtPosition, gbc);

        gbc.gridx = 0;
        gbc.gridy = 6;
        JLabel hireDateLabel = new JLabel("入职日期:");
        hireDateLabel.setFont(labelFont);
        add(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杰克尼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值