Java项目开发:学生社团管理系统

@author:Mr.Gu
@date:2021/5/31


文章目录

  • Java项目开发:学生社团管理系统
  • 项目需求
  • 开发环境
  • 项目效果
  • 二、项目源码
    • 1.创建登录Jframe
  • 2.创建普通用户接口类
  • 3.创建查看社团信息类JFrame
  • 4.创建其他功能JFrame与上述方法同,因代码过于多,不一一展示

项目需求

要求制作一个社团管理系统,要求链接数据库,实现普通用户注册社团,正确登录社团,实现用户可以浏览社团信息,创建社团,且只能创建一个社团,可以申请加入社团,团长
可以进入社团管理系统,对社团进行管理,发布活动等等。

开发环境

eclipse2018版
mysql5.7
jdk1.8
windowsbuilder

项目效果






示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。

二、项目源码

1.创建登录Jframe


public class LogFrm extends JFrame implements ActionListener {boolean flag;private JPanel contentPane;private JTextField nametf;private JPasswordField passwordField;User user = new User();/*** Launch the application.*/public static void main(String[] args) {EventQueue.invokeLater(new Runnable() {public void run() {try {LogFrm frame = new LogFrm();frame.setVisible(true);} catch (Exception e) {e.printStackTrace();}}});}/*** Create the frame.*/public LogFrm() {setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100, 100, 596, 771);JMenuBar menuBar = new JMenuBar();setJMenuBar(menuBar);JMenu menu = new JMenu("编辑注册");menuBar.add(menu);JMenuItem menuItem = new JMenuItem("注册账号");menuItem.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {Regist1 r = new Regist1();r.setVisible(true);}});menu.add(menuItem);contentPane = new JPanel();contentPane.setBackground(Color.WHITE);contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));setContentPane(contentPane);contentPane.setLayout(null);JLabel lblNewLabel = new JLabel("社团管理系统");lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 37));lblNewLabel.setBounds(162, 154, 368, 122);contentPane.add(lblNewLabel);nametf = new JTextField();nametf.setBounds(162, 331, 223, 27);contentPane.add(nametf);nametf.setColumns(10);JLabel lblNewLabel_1 = new JLabel(" 学号 :");lblNewLabel_1.setBounds(40, 334, 81, 21);contentPane.add(lblNewLabel_1);JLabel lblNewLabel_2 = new JLabel("密码 :");lblNewLabel_2.setBounds(50, 411, 81, 21);contentPane.add(lblNewLabel_2);JButton button = new JButton("重置");button.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {rest();}});button.setBounds(88, 539, 123, 29);contentPane.add(button);JButton btnNewButton = new JButton("登录");btnNewButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {try {login();} catch (HeadlessException | SQLException e1) {e1.printStackTrace();}}});btnNewButton.setBounds(340, 539, 123, 29);contentPane.add(btnNewButton);passwordField = new JPasswordField();passwordField.setBounds(162, 408, 223, 27);contentPane.add(passwordField);this.setLocationRelativeTo(null);}protected void login() throws HeadlessException, SQLException {boolean xyz = false;Mysql1 mysql = new Mysql1();mysql.connectSQL();String nameText = nametf.getText();String pwdText = new String(passwordField.getText());User user = new User(nameText, pwdText);/*** 用于数据库连接*/Connection connection = null;if (StringUtil.isEmpty(nameText)) {JOptionPane.showMessageDialog(null, "用户名为空");} else {if (StringUtil.isEmpty(pwdText)) {JOptionPane.showMessageDialog(null, "密码不能为空");} else {try {this.flag = mysql.loginMatch(nameText, pwdText);} catch (SQLException e2) {e2.printStackTrace();} catch (Exception e2) {e2.printStackTrace();} // 清空输入栏rest();// 如果用户名判断成功则关闭login窗口并打开Spider窗口,否则状态栏显示loadfail;if (flag) {this.dispose();setall(nametf.getText());MainFrm mainFrm = new MainFrm(setall(nameText));mainFrm.setVisible(true);} else {JOptionPane.showMessageDialog(null, "账号或密码错误");}}}}private User setall(String id) throws SQLException {String url = "jdbc:mysql://localhost:3306/student?useSSL=false";// url是固定的// jdbc:mysql://localhost:3036/数据库名String user3 = "root";// 这里一般是rootString password = "root";// 这是登陆数据库的密码,我的密码为空String word3 = "select * from userinfo";ResultSet resultSet = null;boolean x = false;String anameString = new String();Connection con = (Connection) DriverManager.getConnection(url, user3, password);// 创建连接对象,来连接数据库PreparedStatement ps0 = con.prepareStatement(word3);// 创建执行对象resultSet = ps0.executeQuery(word3);while (resultSet.next()) {if (resultSet.getString("Id").equals(id)) {user.setSex(resultSet.getString("sex"));user.setName(resultSet.getString("name"));user.setId(resultSet.getString("Id"));user.setActivityID(resultSet.getString("activityID"));user.setManage(resultSet.getString("isManage"));}}return user;}/*** 选择shift tab 整体往前捻 重置事件*/protected void rest() {nametf.setText("");passwordField.setText("");}@Overridepublic void actionPerformed(ActionEvent e) {}
}

2.创建普通用户接口类

public class MainFrm extends JFrame {private JPanel contentPane;private JDesktopPane desktopPane;public static User user;/*** Launch the application.[[*//*** Create the frame.*/MainFrm() {super();}public MainFrm(User user1) throws SQLException {this.user = user1;applyhave();setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100, 100, 750, 580);JMenuBar menuBar = new JMenuBar();setJMenuBar(menuBar);JMenu menu = new JMenu("\u7F16\u8F91");menuBar.add(menu);JMenuItem menuItem = new JMenuItem("退出");menuItem.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {//              setDefaultCloseOperation(3);    //直接关闭程序System.exit(0);}});menu.add(menuItem);contentPane = new JPanel();contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));contentPane.setLayout(new BorderLayout(0, 0));setContentPane(contentPane);desktopPane = new JDesktopPane();desktopPane.setBackground(Color.WHITE);contentPane.add(desktopPane, BorderLayout.CENTER);JLabel label = new JLabel("用户界面");label.setFont(new Font("宋体", Font.BOLD, 24));label.setBounds(268, 103, 200, 118);desktopPane.add(label);JButton button = new JButton("查看社团信息");button.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {Show show = new Show(user);show.setVisible(true);}});button.setBounds(15, 311, 178, 76);desktopPane.add(button);JButton button_1 = new JButton("创建社团");button_1.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {boolean s = false;CreatAct act = new CreatAct();act.setVisible(true);}});button_1.setBounds(243, 311, 178, 76);desktopPane.add(button_1);JButton button_2 = new JButton("进入管理员界面");button_2.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {if (user.getManage().equals("1")) {Manager manager;try {manager = new Manager(user);manager.setVisible(true);dispose();} catch (SQLException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}JOptionPane.showMessageDialog(null, "登录成功");} else {JOptionPane.showMessageDialog(null, "您没有权限");}}});button_2.setBounds(483, 311, 178, 76);desktopPane.add(button_2);this.setLocationRelativeTo(null);}private void applyhave() throws SQLException {String url = "jdbc:mysql://localhost:3306/student?useSSL=false&useUnicode=true&characterEncoding=utf8";// url是固定的String user3 = "root";// 这里一般是rootString password = "root";// 这是登陆数据库的密码,我的密码为空String word3 = "select * from applyhave";ResultSet resultSet = null;String anameString = new String();Connection con = (Connection) DriverManager.getConnection(url, user3, password);// 创建连接对象,来连接数据库PreparedStatement ps0 = con.prepareStatement(word3);// 创建执行对象resultSet = ps0.executeQuery(word3);while (resultSet.next()) {if (resultSet.getString("Stuname").equals(user.getName())) {if (resultSet.getString("result").equals("1")) {     JOptionPane.showMessageDialog(null, "您申请加入的社团申请成功");String word5 = "DELETE FROM applyhave WHERE Stuname = '" + user.getName() + "'";PreparedStatement ps4 = con.prepareStatement(word5);// 创建执行对象ps4.executeUpdate();ps4.close();}}}}}
}

3.创建查看社团信息类JFrame

public class Show extends JFrame {private JTable table;private User user;public Show(User user) {this.user=user;setFocusable(true);setBounds(100, 100, 1002, 697);JScrollPane scrollPane = new JScrollPane();JButton btnNewButton = new JButton("申请加入社团");btnNewButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {ApplyAct applyAct =new ApplyAct(user);applyAct.setVisible(true);}});GroupLayout groupLayout = new GroupLayout(getContentPane());groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addGap(180).addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 612, GroupLayout.PREFERRED_SIZE).addContainerGap(188, Short.MAX_VALUE)).addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup().addContainerGap(771, Short.MAX_VALUE).addComponent(btnNewButton).addGap(86)));groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout.createSequentialGroup().addGap(125).addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 348, GroupLayout.PREFERRED_SIZE).addGap(57).addComponent(btnNewButton).addContainerGap(82, Short.MAX_VALUE)));table = new JTable();table.setModel(new DefaultTableModel(new Object[][] {},new String[] {"\u793E\u56E2\u540D", "\u793E\u56E2\u4FE1\u606F", "\u793E\u56E2ID", "\u56E2\u957F", "\u662F\u5426\u6EE1\u5458"}));scrollPane.setViewportView(table);getContentPane().setLayout(groupLayout);loadData();//传入数据this.setLocationRelativeTo(null);}//  将数据库中数据传入中可以发挥private void loadData() {//      获取表格数据DefaultTableModel model = (DefaultTableModel) table.getModel();
//      每次添加的时候清空表格的原始数据model.setRowCount(0);
//      模拟数据
//      model.addRow("社团名称,社团人数,团长,是否满员");model.setRowCount(0);String url="jdbc:mysql://localhost:3306/student?useSSL=false&useUnicode=true&characterEncoding=utf8";//url是固定的 jdbc:mysql://localhost:3036/数据库名String user3="root";//这里一般是rootString password="root";//这是登陆数据库的密码,我的密码为空String word="select * from activity";try {Class.forName("com.mysql.jdbc.Driver");//加载驱动类Connection con= DriverManager.getConnection(url, user3, password);//创建连接对象,来连接数据库ResultSet resultSet =null;PreparedStatement ps=con.prepareStatement(word);//创建执行对象resultSet=ps.executeQuery();while (resultSet.next()) {Object[] objs1 = {resultSet.getString("ActInfo"),resultSet.getString("ActId"),resultSet.getString("ManagerId"),resultSet.getString("Adtname"),"否"};model.addRow(objs1);}ps.close();con.close();} catch (ClassNotFoundException e2) {    //这里是错误捕捉,如果出错,计算机就会执行这段代码,下面的也是e2.printStackTrace();} catch (SQLException e1) {e1.printStackTrace();}dispose();}
}

4.创建其他功能JFrame与上述方法同,因代码过于多,不一一展示

Java项目开发:学生社团管理系统相关推荐

  1. ssm毕设项目高校学生社团管理系统n4pcu(java+VUE+Mybatis+Maven+Mysql+sprnig)

    ssm毕设项目高校学生社团管理系统n4pcu(java+VUE+Mybatis+Maven+Mysql+sprnig) 项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql + ...

  2. Java项目:高校学生社团活动管理系统(java+springboot+freemark+jpa+mysql)

    源码获取:博客首页 "资源" 里下载! 前台: 1.社团信息浏览搜索.社团活动风采.新闻信息浏览搜索. 2.学生注册登录. 3.登录后可自己申请创建社团,也可申请加入其他社团活动. ...

  3. Java项目:教务处学生成绩管理系统(java+JSP+bootstrap+servlet+Mysql)

    源码获取:俺的博客首页 "资源" 里下载! 项目介绍 本项目包含管理员.教师.学生三种角色: 用户角色包含以下功能: 修改密码,查看自己的信息,查看自己的成绩,登录界面等功能. 管 ...

  4. Java项目开发(航空管理系统)

    主要内容: 1.此项目所需的准备事项 1.1 数据库的准备 通过试题给出的sql语句,按照试题要求在navicat中新建一个名为session1的数据库,如何新建查询贴入建表语句,并且运行这些语句,待 ...

  5. SSM毕设项目学生社团管理系统pyl5z(java+VUE+Mybatis+Maven+Mysql)

    SSM毕设项目学生社团管理系统pyl5z(java+VUE+Mybatis+Maven+Mysql) 项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX ...

  6. Java项目开发,学生信息管理系统

    Java项目开发,学生信息管理系统 @author:Mr.Gu @date:2020/5/31 开发时间大二年级,数据结构综合实习 文章目录 Java项目开发,学生信息管理系统 开发效果 开发要求 开 ...

  7. (附源码)SSM学生社团管理系统JAVA计算机毕业设计项目

    项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclis ...

  8. java社团管理系统文库_学生社团管理系统的设计与实现

    学生社团管理系统的设计与实现 综合课程设计 题目 学生社团管理系统 学 院 计算机科学与工程学院 专 业 软件工程 班 级 学生姓名 学号 指导教师 评阅教师 时 间 目 录 摘 要I Abstrac ...

  9. Java SpringMVC毕业项目实战-学生信息管理系统

    目录 摘要设计: 系统功能概述: B站视频演示:java毕业设计-SSM学生信息管理系统.mp4 主要功能截图: 主要数据库设计: 论文结构目录设计 : 获取完整源码: 摘要设计:文末获取源码联系 本 ...

最新文章

  1. RAD Studio XE2/XE3 官方 ISO 下载地址 (2012-09-05更新)
  2. 通过url,获取html内容,并解析
  3. 成功解决 keras\callbacks.py:999: UserWarning: `epsilon` argument is deprecated and will be removed, use
  4. java类型比较_Java数据类型的比较
  5. 怎么说呢。留个纪念,关于字符串的重载
  6. mybatis中的查询缓存
  7. CSS3中制作倒影box-reflect
  8. Linux下读写芯片的I2C寄存器
  9. 在Java中使用Google的协议缓冲区
  10. 【CentOS 7LAMP架构4】,PHP5和PHP7的安装和配置#171219
  11. 阿里巴巴内部开发手册
  12. Java_单例/多例设计
  13. 频繁模式挖掘apriori算法介绍及Java实现
  14. kis 2009 key/卡巴斯基2009 key/kis 8.0 0.454 key/卡巴斯基 8.0 0.454 key
  15. 计算机驱动程序属于系统还是软件,什么是VGA驱动程序?
  16. 公司部门英文缩写简称收集
  17. riot账号服务器互通吗,云顶之弈手游和PC数据互通吗账号数据同步分析
  18. 基于React Native和Ethers.js的电子钱包(二):路由和导航
  19. 佳音图php,PHP5实例教程 简简单单生成条形码
  20. File 里面的flush()和close()

热门文章

  1. Remote table-valued function calls are not allowed.
  2. [渝粤教育] 浙江大学 2021秋冬微积分(一) 参考 资料
  3. leetcode刷题规划
  4. mac连接蓝牙耳机只有一个有声音
  5. 金三银四,磨砺锋芒;剑指大厂,扬帆起航(2020年最全大厂WEB前端面试题精选)上
  6. 【51单片机学习笔记】基于STC11F04E的蜂鸣器音乐播放器
  7. 获得淘宝商品详情原数据接口调用展示
  8. ddr走线教程_DDR走线规则
  9. 解决必应biying搜索跳转到百度www.baidu.com搜索的解决方法
  10. 高中英语话题阅读 计算机,高中英语必修二Unit 3 Computers阅读课的教学设计