前言:
項目是使用Java swing+mysql開發,可實現基礎數據維護、用戶登錄注冊、社團信息列表查看、社團信息添加、社團信息修改、社團信息刪除以及退出注銷等功能、界面設計比較簡單易學、適合作為Java課設設計以及學習技術使用。
引言
隨著全球信息化的迅猛發展,高效規模不斷壯大,協會人數急劇增加,有必要開發一個學生社團管理系統來提高社聯對社團的管理效率,學生社團管理系統將逐漸取代傳統的人工管理模式。本文采用Java+swing+mysql作為開發技術,以Java為編程語言,開發一個基javaSwing的學生社團管理系統。該系統可以對社團工作進行快速、高效的管理,為社團之間和社團會員之間提供一個良好的信息交流的平臺,讓社團成員可以展示自己的風采,及時了解社團的新動態,營造一個現代化的學習生活環境。
主要技術和工具:
eclipse+JDK1..8+Navicat 數據庫可視化工具+swing +mysql
功能截圖:
用戶登錄注冊:
用戶輸入賬號密碼進行登錄、沒注冊的用戶點擊注冊按鈕進行用戶信息注冊、注冊后即可成功登錄查看社團信息。
社團列表查看:
社團信息添加:
錄入社團相關信息完成社團添加操作
社團信息修改:
社團信息刪除:
注銷退出:
注銷退出執行頁面關閉操作。
關鍵代碼:
用戶登錄:
- /**
- * 登錄主界面
- * @author admin
- *
- */
- public class LoginFrame extends JFrame {
- private static final long serialVersionUID = 1L;
- // 登錄背景和 Logo 圖片顏色
- Color logoPaneColor = new Color(230, 230, 250);
- Color mainPaneColor = new Color(230, 230, 250);
- Color mainFrameColor = new Color(186, 110, 64);
- Color logoFramColor = new Color(186, 110, 64);
- JLayeredPane layeredPane = new JLayeredPane(); // 面板層
- ImageIcon bgImage = new ImageIcon("./img/bgImage.png"); // 背景圖片
- ImageIcon lgImage = new ImageIcon("./img/login1.png"); // 登錄圖片
- JPanel bgPanel = new JPanel(); // 背景面板
- JPanel mainPanel = new JPanel(); // 登陸面板
- JPanel logoPanel = new JPanel(); // 企業logo
- final JLabel user_name = new JLabel("用戶名:"); // 登錄標簽
- final JLabel user_password = new JLabel("密 碼:");// 密碼標簽
- JButton button_ok = new JButton("登陸"); // 確認按鈕
- JButton btRegister=new JButton("注冊"); // 注冊按鈕
- JButton button_cansel = new JButton("退出");// 退出按鈕
- JTextField text_name = new JTextField(""); // 登陸用戶名
- JPasswordField text_password = new JPasswordField(""); // 登陸密碼
- JFrame loginFrame = null; // 登錄窗口類
- /**
- * 登錄按鈕點擊監聽類:收集登錄信息,并校驗;校驗成功,則進入系統主頁面
- * @author admin
- *
- */
- class LoginOKAction implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- String userName = text_name.getText();
- String password = new String(text_password.getPassword());
- // 判空操作
- if(userName.equals("") || password.equals("")) {
- // 彈出提示信息,操作結束
- JOptionPane.showMessageDialog(loginFrame, "登錄用戶名和密碼不能為空!", "提示", JOptionPane.PLAIN_MESSAGE);
- return;
- }
- // 根據用戶名和密碼進行查詢
- boolean flag = UserManager.login(userName, password);
- // 校驗失敗,返回
- if(!flag) {
- JOptionPane.showMessageDialog(loginFrame, "登錄用戶名不匹配!", "提示", JOptionPane.PLAIN_MESSAGE);
- return;
- }
- // 成功,進入主頁
- setVisible(false);
- new MainFrame().setVisible(true);
- }
- }
- /**
- * 登錄 Frame 的構造函數
- */
- public LoginFrame() {
- super("學生社團管理系統");
- initialize();
- this.loginFrame = this;
- }
- /**
- * 程序 main 函數
- * @param args
- */
- public static void main(String[] args) {
- // 創建登錄 Frame 進入應用登錄頁面
- new LoginFrame();
- }
- }
添加社團信息:
- public class AddFrame extends AbstractFormFrame {
- private static final long serialVersionUID = 1L;
- /**
- * 主界面配置
- */
- public AddFrame() {
- super("添加");
- // 居中
- GUIUtil.toCenter(this);
- }
- @Override
- public void submit(CommunityInfo community) {
- // 判唯一
- CommunityInfo tmp = CommunityManager.queryOne(community.getName());
- if (tmp != null) {
- JOptionPane.showMessageDialog(this, "社團名稱已存在!");
- return;
- }
- // 添加到記錄列表
- CommunityManager.add(community);
- // 提示
- JOptionPane.showMessageDialog(this, "添加成功!");
- }
- }
備注:項目來于網絡、作者整理優化測試、若有侵權聯系作者刪除
總結:
經過近期對 java 相關知識面向對象程序設計、Java swing等的掌握和學習,讓我更加了解到 java 學習的重要性。在開發這個社團系統,我完成多個實驗以及測試,在這個階段的學習開發中,我從認識到熟悉,而后到能夠自主運用。通過對 java swing知識以及數據庫的設計相關的了解,我發現它確實有很多方便之處,它集抽象性、封裝性、繼承性和多態性于一體,實現了代碼重用和代碼擴充,提高了軟件開發的效率。對于我們這個專業來說學好 java 語言是很重要的,所以在開發這個項目的過程中我都盡力理解 java 編程思想、掌握基本技巧,盡量學到最多的知識。 我學習程序設計的基本目的就是培養描述實際問題的程序化解決方案的關鍵技能,總體來說 java 面向對象程序設計是一門實踐性比較強的語言。
到此這篇關于基于JavaSwing+mysql開發一個學生社團管理系統設計和實現的文章就介紹到這了,更多相關Java學生社團管理系統內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!
原文鏈接:https://blog.csdn.net/v123411739/article/details/119700990