Eclipse+Java+Swing实现学校教材管理系统

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 RDS MySQL Serverless,价值2615元额度,1个月
简介: Eclipse+Java+Swing实现学校教材管理系统

一、系统介绍


本系统实现的功能:管理员登录、教材的增删改查、导出PDF。


JDK:1.8


数据库:Mysql8.0.13


二、系统展示


1.登录页


20210102121719439.jpg


2.主页面


20210102121745454.jpg


3.导出表单


20210102121824984.jpg


三、部分代码


DBUtil.java


package com.sjsq;
/**
 * 此类用以载入数据库
 * @author 郑伟
 * */
import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;
public class DBUtil {
  // 数据库驱动名
  private static String DriverName = "com.mysql.cj.jdbc.Driver";
  // 数据库协议
  private static String dbUril = "jdbc:mysql://localhost:3306/teachbook_management_swing?serverTimezone=UTC";
  // 数据库用户名
  private static String dbName = "root";
  // 数据库密码
  private static String dbPassword = "admin";
  public static Connection getlink() {
    try {
      Class.forName(DriverName);
      System.out.println("正在加载...");
      Connection connection = DriverManager.getConnection(dbUril, dbName, dbPassword);
      System.out.println("连接成功!");
      // ResultSet rs = stmt.executeQuery(sql);
      return connection;
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, "数据库链接失败!", "警告", JOptionPane.ERROR_MESSAGE);
      System.out.println("连接失败");
      e.printStackTrace();
      return null;
    }
  }
  public static void main(String args[]) {
    getlink();
  }
}

Login.java

package com.sjsq;
/**
 * 此类为登录窗口类
 * 由Visual Editor 生成
 * @author 郑伟
 * @author shuijianshiqing
 * @date 2020-12-30
 * 
 * */
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.jvnet.substance.skin.SubstanceCremeLookAndFeel;
public class Login extends JFrame implements WindowListener, ActionListener, KeyListener {
  private static final long serialVersionUID = 1L;
  private JPanel jContentPane = null;
  private JButton jButton = null;
  private JButton jButton1 = null;
  private JLabel jLabel = null;
  private JLabel jLabel1 = null;
  private JLabel jLabel2 = null;
  private JTextField jTextField = null;
  private JPasswordField jPasswordField = null;
  private Connection connection; // @jve:decl-index=0:
  private Statement stmt;
  private String username;
  private int flag = 0;
  /**
   * This is the default constructor
   */
  public Login() {
    super();
    try {
      UIManager.setLookAndFeel(new SubstanceCremeLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
      // TODO 自动生成 catch 块
      e.printStackTrace();
    }
    initialize();
    Dimension screen = getToolkit().getScreenSize(); // 得到屏幕尺寸
    // pack(); //窗口适应组件尺寸
    setLocation((screen.width - getWidth()) / 2, (screen.height - getHeight()) / 2);// 使窗口出现在屏幕中间
    this.setResizable(false);// 不可缩放~~
    this.addWindowListener(this);
    connection = DBUtil.getlink();
    try {
      stmt = connection.createStatement();
    } catch (SQLException e) {
      // TODO 自动生成 catch 块
      e.printStackTrace();
    } // 链接数据库
  }
  /**
   * This method initializes this
   * 
   * @return void
   */
  private void initialize() {
    // 登录窗口大小
    this.setSize(500, 308);
    this.setContentPane(getJContentPane());
    this.setTitle("欢迎登录教材管理系统");
  }
  // 登录函数
  private void denglu() {
    if (flag > 2) {
      jButton.setEnabled(false);
    }
    this.jLabel.setText("登录中请稍候。。");
    username = jTextField.getText();
    String pwd = String.valueOf(jPasswordField.getPassword());
    String yz = new String("Select username,pswd,yanzheng from login where username='" + username + "'");
    try {
      ResultSet result = stmt.executeQuery(yz);
      if (result.next()) { // 用户名存在~
        if (pwd.equals(result.getString(2))) {
          if (result.getString(3).equals("1")) { // 验证权限
            this.jLabel.setText("              登录成功");
            this.flag = 1; // 若取得数据的第三项是1的话,则把flag设置为1
            this.setVisible(false);
            XFlashScreen splash = new XFlashScreen();
            splash.start(); // 运行启动界面
          } else if (result.getString(3).equals("4")) { // 验证权限
            this.jLabel.setText("              登录成功");
            this.flag = 4; // 若取得数据的第三项是4的话,则把flag设置为4
            this.setVisible(false);
          }
        } else {
          this.jLabel.setText("            密码错误 -_-!");
          flag++;
        }
      } else {
        this.jLabel.setText("              没有此用户 -_-!");
        flag++;
      }
    } catch (SQLException e1) {
      e1.printStackTrace();
    }
  }
  /**
   * This method initializes jContentPane
   * 
   * @return javax.swing.JPanel
   */
  private JPanel getJContentPane() {
    if (jContentPane == null) {
      jLabel1 = new JLabel();
      jLabel1.setBounds(new Rectangle(160, 55, 57, 17));
      jLabel1.setText("账号:");
      jLabel2 = new JLabel();
      jLabel2.setBounds(new Rectangle(160, 100, 55, 17));
      jLabel2.setText("密码:");
      jLabel = new JLabel();
      jLabel.setBounds(new Rectangle(180, 150, 177, 14));
      jLabel.setText("不能尝试超过4次哦~(*^__^*) ");
      jContentPane = new JPanel();
      jContentPane.setLayout(null);
      jContentPane.setBackground(new Color(255, 255, 225));
      jContentPane.add(getJButton(), null);
      jContentPane.add(getJButton1(), null);
      jContentPane.add(jLabel, null);
      jContentPane.add(jLabel1, null);
      jContentPane.add(jLabel2, null);
      jContentPane.add(getJTextField(), null);
      jContentPane.add(getJPasswordField(), null);
    }
    return jContentPane;
  }
  public void windowActivated(WindowEvent arg0) {
  }
  public void windowClosed(WindowEvent arg0) {
    System.exit(0);
  }
  public void windowClosing(WindowEvent arg0) {
  }
  public void windowDeactivated(WindowEvent arg0) {
  }
  public void windowDeiconified(WindowEvent arg0) {
  }
  public void windowIconified(WindowEvent arg0) {
  }
  public void windowOpened(WindowEvent arg0) {
  }
  /**
   * This method initializes jButton
   * 
   * @return javax.swing.JButton
   */
  private JButton getJButton() {
    if (jButton == null) {
      jButton = new JButton(new ImageIcon("./pic/key.gif"));
      jButton.setBounds(new Rectangle(120, 180, 83, 25));
      // jButton.setFont(new Font("Dialog", Font.BOLD, 11));
      jButton.setText("登录");
      jButton.addActionListener(this);
    }
    return jButton;
  }
  /**
   * This method initializes jButton1
   * 
   * @return javax.swing.JButton
   */
  private JButton getJButton1() {
    if (jButton1 == null) {
      jButton1 = new JButton(new ImageIcon("./pic/exit.gif"));
      jButton1.addActionListener(this);
      jButton1.setBounds(new Rectangle(300, 180, 83, 25));
      // jButton1.setFont(new Font("Dialog", Font.BOLD, 11));
      jButton1.setText("退出");
    }
    return jButton1;
  }
  /**
   * This method initializes jTextField
   * 
   * @return javax.swing.JTextField
   */
  private JTextField getJTextField() {
    if (jTextField == null) {
      jTextField = new JTextField();
      jTextField.setBounds(new Rectangle(200, 45, 156, 35));
      jTextField.addKeyListener(this);
    }
    return jTextField;
  }
  /**
   * This method initializes jPasswordField
   * 
   * @return javax.swing.JPasswordField
   */
  private JPasswordField getJPasswordField() {
    if (jPasswordField == null) {
      jPasswordField = new JPasswordField();
      jPasswordField.setBounds(new Rectangle(200, 90, 156, 35));
      jPasswordField.addKeyListener(this);
    }
    return jPasswordField;
  }
  public void actionPerformed(ActionEvent e) {
    if ((JButton) e.getSource() == jButton1) {
      this.dispose();
      System.exit(0);
    } else if ((JButton) e.getSource() == jButton) {
      denglu();
    }
  }
  public void keyPressed(KeyEvent arg0) {
  }
  public void keyReleased(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER)/** 判断是否回车 */
      denglu();
  }
  public void keyTyped(KeyEvent arg0) {
  }
  public static void main(String[] args) {
    Login aaa = new Login();
    aaa.setVisible(true);
  }
}

MyTable.java

package com.sjsq;
import javax.swing.table.AbstractTableModel;
class MyTable extends AbstractTableModel {
  Object[][] p = null;
  String[] n = null;
  MyTable(Object[][] p, String[] n) {
    this.p = p;
    this.n = n;
  }
  public int getColumnCount() {
    return n.length;
  }
  public int getRowCount() {
    return p.length;
  }
  public Object getValueAt(int row, int col) {
    return p[row][col];
  }
  public String getColumnName(int col) {
    return n[col];
  }
  public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
  }
  public boolean isCellEditable(int row, int col) {
    if (col == 0) {
      return false;
    } else {
      return true;
    }
  }
  public void setValueAt(Object value, int row, int col) {
    {
      p[row][col] = value;
    }
  }
}

XMainFrame.java

package com.sjsq;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Rectangle;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
public class XMainFrame extends JFrame implements WindowListener {
  private static final long serialVersionUID = 1L;
  private JPanel jContentPane = null;
  private JTabbedPane jTabbedPane = null;
  XAddForm xaddform;
  /**
   * This is the default constructor
   */
  public XMainFrame() {
    super();
    xaddform = new XAddForm();
    initialize();
    Dimension screen = getToolkit().getScreenSize(); // 得到屏幕尺寸
    // pack(); //窗口适应组件尺寸
    setLocation((screen.width - 800) / 2, (screen.height - 600) / 2);
  }
  /**
   * This method initializes this
   * 
   * @return void
   */
  private void initialize() {
    this.setSize(567, 401);
    this.setContentPane(getJContentPane());
    this.setTitle("教材管理系统");
  }
  /**
   * This method initializes jContentPane
   * 
   * @return javax.swing.JPanel
   */
  private JPanel getJContentPane() {
    if (jContentPane == null) {
      GridBagConstraints gridBagConstraints = new GridBagConstraints();
      gridBagConstraints.fill = GridBagConstraints.BOTH;
      gridBagConstraints.gridwidth = -1;
      gridBagConstraints.gridx = 1;
      gridBagConstraints.gridy = 1;
      gridBagConstraints.ipadx = -5;
      gridBagConstraints.ipady = -7;
      gridBagConstraints.weightx = 1.0;
      gridBagConstraints.weighty = 1.0;
      gridBagConstraints.gridheight = -1;
      jContentPane = new JPanel();
      jContentPane.setLayout(new GridBagLayout());
      jContentPane.add(getJTabbedPane(), gridBagConstraints);
    }
    return jContentPane;
  }
  /**
   * This method initializes jTabbedPane
   * 
   * @return javax.swing.JTabbedPane
   */
  private JTabbedPane getJTabbedPane() {
    if (jTabbedPane == null) {
      jTabbedPane = new JTabbedPane();
      xaddform.setBounds(new Rectangle(1, 2, 558, 366));
      jTabbedPane.addTab("表单提交", null, xaddform, null);
    }
    return jTabbedPane;
  }
  public void windowActivated(WindowEvent arg0) {
    // TODO 自动生成方法存根
  }
  public void windowClosed(WindowEvent arg0) {
    // TODO 自动生成方法存根
  }
  public void windowClosing(WindowEvent arg0) {
    // TODO 自动生成方法存根
    System.exit(0);
  }
  public void windowDeactivated(WindowEvent arg0) {
    // TODO 自动生成方法存根
  }
  public void windowDeiconified(WindowEvent arg0) {
    // TODO 自动生成方法存根
  }
  public void windowIconified(WindowEvent arg0) {
    // TODO 自动生成方法存根
  }
  public void windowOpened(WindowEvent arg0) {
    // TODO 自动生成方法存根
  }
} 


四、其他


1.其他系统实现


Java+JSP系统系列实现


Java+JSP实现学生图书管理系统

Java+JSP实现学生信息管理系统

Java+JSP实现用户信息管理系统


Java+Servlet+JSP系统系列实现


Java+Servlet+JSP实现航空订票系统

Java+Servlet+JSP实现新闻发布系统

Java+Servlet+JSP实现图书管理系统

Java+Servlet+JSP实现停车场管理系统

Java+Servlet+JSP实现房屋租赁管理系统

Java+Servlet+JSP实现学生选课管理系统

Java+Servlet+JSP实现宠物诊所管理系统

Java+Servlet+JSP实现学生宿舍管理系统

Java+Servlet+JSP实现学生信息管理系统

Java+Servlet+JSP实现学生成绩管理系统1

Java+Servlet+JSP实现学生成绩管理系统2


Java+SSM系统系列实现


Java+SSM+JSP实现宠物商城系统

Java+SSM+JSP实现超市订单系统

Java+SSM+JSP实现图书管理系统

Java+SSM+Easyui实现网上考试系统

Java+SSM+Layui实现学生成绩管理系统

Java+SSM+Bootstrap实现学生信息管理系统

Java+SSM+Bootstrap+Maven实现网上书城系统

Java+SSM+Bootstrap+Maven实现学校教务管理系统


Java+SSH系统系列实现


Java+SSH+Bootstrap实现在线考试系统

Java+SSH+JSP实现医院在线挂号系统


Java+Springboot系统系列实现


Java+Springboot+H-ui实现营销管理系统

Java+Springboot+Bootstrap实现网上商城系统

Java+Springboot+Bootstrap+Maven实现景区旅游管理系统


JavaSwing+Mysql系统系列实现


Java+Swing实现斗地主游戏

Java+Swing实现图书管理系统

Java+Swing实现医院管理系统

Java+Swing实现考试管理系统

Java+Swing实现酒店管理系统

Java+Swing实现超市管理系统

Java+Swing实现网上订餐系统

Java+Swing实现电影购票系统

Java+Swing实现仓库管理系统1

Java+Swing实现仓库管理系统2

Java+Swing实现进销存管理系统

Java+Swing实现通讯录管理系统

Java+Swing实现停车场管理系统

Java+Swing实现学生宿舍管理系统

Java+Swing实现学生选课管理系统

Java+Swing实现学生成绩管理系统

Java+Swing实现学校教材管理系统

Java+Swing实现学校教务管理系统

Java+Swing实现企业人事管理系统

Java+Swing实现电子相册管理系统

Java+Swing实现学生信息管理系统1

Java+Swing实现学生信息管理系统2

Java+Swing实现自助取款机(ATM)系统


JavaSwing+Txt系统系列实现


Java+Swing实现超市管理系统-TXT存储信息

Java+Swing实现宠物商店管理系统-TXT存储信息

Java+Swing实现自助取款机(ATM)系统-TXT存储信息


相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
存储 Java 关系型数据库
农产品管理系统【GUI/Swing+MySQL】(Java课设)
农产品管理系统【GUI/Swing+MySQL】(Java课设)
19 1
|
1月前
|
存储 Java 关系型数据库
个人成绩信息管理系统【GUI/Swing+MySQL】(Java课设)
个人成绩信息管理系统【GUI/Swing+MySQL】(Java课设)
21 0
|
1月前
|
存储 Java 关系型数据库
酒店管理系统【GUI/Swing+MySQL】(Java课设)
酒店管理系统【GUI/Swing+MySQL】(Java课设)
23 1
|
1月前
|
存储 Java 关系型数据库
社区医院管理服务系统【GUI/Swing+MySQL】(Java课设)
社区医院管理服务系统【GUI/Swing+MySQL】(Java课设)
26 1
|
1月前
|
存储 Java 关系型数据库
仓库管理系统【GUI/Swing+MySQL】(Java课设)
仓库管理系统【GUI/Swing+MySQL】(Java课设)
20 0
|
1月前
|
存储 Java 关系型数据库
游乐场管理系统【GUI/Swing+MySQL】(Java课设)
游乐场管理系统【GUI/Swing+MySQL】(Java课设)
17 0
|
1月前
|
存储 Java 关系型数据库
影碟出租管理系统【GUI/Swing+MySQL】(Java课设)
影碟出租管理系统【GUI/Swing+MySQL】(Java课设)
17 0
|
1月前
|
存储 Java 关系型数据库
实验室设备管理系统【GUI/Swing+MySQL】(Java课设)
实验室设备管理系统【GUI/Swing+MySQL】(Java课设)
19 0
|
1月前
|
存储 Java 关系型数据库
请销假管理系统【GUI/Swing+MySQL】(Java课设)
请销假管理系统【GUI/Swing+MySQL】(Java课设)
15 0
|
1月前
|
存储 Java 关系型数据库
某电力公司收费管理系统【GUI/Swing+MySQL】(Java课设)
某电力公司收费管理系统【GUI/Swing+MySQL】(Java课设)
16 0

推荐镜像

更多