826220679@qq.com
5 小时以前 69b40096cb0ae965f2a3e92672b880edfe7d04d2
src/denglu/Denglu.java
@@ -10,6 +10,7 @@
import user.Usrdell;
import Mqttmessage.Client;
import login.LoginVerifier;
import publicway.buttonset;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
@@ -22,11 +23,10 @@
    private JPasswordField passwordField;
    private JCheckBox rememberMe;
    private JButton loginButton;
    private JButton registerButton;
    private Map<String, Map<String, String>> translations;
    private JPanel mainPanel;
    private JLabel usernameLabel, passwordLabel;
    private JLabel forgotPassword, noAccountLabel, signupLink, appInfoLabel;
    private JLabel forgotPassword, noAccountLabel, signupLink;
    // 主题颜色
    private final Color THEME_COLOR = new Color(46, 139, 87);
@@ -56,7 +56,6 @@
        zh.put("sign_up", "立即注册");
        zh.put("app_title", "智能割草系统");
        zh.put("window_title", "智能割草系统 - 登录");
        zh.put("app_info", "智能割草系统 © 2023 - 智能割草解决方案");
        zh.put("register_button", "注册新账户");
        translations.put("zh", zh);
@@ -71,7 +70,6 @@
        en.put("sign_up", "Sign Up");
        en.put("app_title", "Smart Mowing System");
        en.put("window_title", "Smart Mowing System - Login");
        en.put("app_info", "Smart Mowing System © 2023 - Intelligent Lawn Care");
        en.put("register_button", "Create New Account");
        translations.put("en", en);
@@ -86,7 +84,6 @@
        es.put("sign_up", "Regístrate");
        es.put("app_title", "Sistema de Corte Inteligente");
        es.put("window_title", "Sistema de Corte Inteligente - Iniciar Sesión");
        es.put("app_info", "Sistema de Corte Inteligente © 2023 - Soluciones Inteligentes");
        es.put("register_button", "Crear Nueva Cuenta");
        translations.put("es", es);
@@ -101,7 +98,6 @@
        fr.put("sign_up", "S'inscrire");
        fr.put("app_title", "Système de Tonte Intelligent");
        fr.put("window_title", "Système de Tonte Intelligent - Connexion");
        fr.put("app_info", "Système de Tonte Intelligent © 2023 - Solutions de Tonte");
        fr.put("register_button", "Créer un Nouveau Compte");
        translations.put("fr", fr);
@@ -116,7 +112,6 @@
        de.put("sign_up", "Registrieren");
        de.put("app_title", "Intelligentes Mähsystem");
        de.put("window_title", "Intelligentes Mähsystem - Anmeldung");
        de.put("app_info", "Intelligentes Mähsystem © 2023 - Mählösungen");
        de.put("register_button", "Neues Konto Erstellen");
        translations.put("de", de);
    }
@@ -158,12 +153,12 @@
        // 主表单区域
        JPanel formPanel = createFormPanel();
        
        // 底部应用信息
        JPanel appInfoPanel = createAppInfoPanel();
        // 底部面板(包含注册链接)
        JPanel bottomPanel = createBottomPanel();
        
        mainPanel.add(topPanel, BorderLayout.NORTH);
        mainPanel.add(formPanel, BorderLayout.CENTER);
        mainPanel.add(appInfoPanel, BorderLayout.SOUTH);
        mainPanel.add(bottomPanel, BorderLayout.SOUTH);
        
        add(mainPanel);
    }
@@ -226,75 +221,21 @@
        rememberForgotPanel.add(rememberMe, BorderLayout.WEST);
        rememberForgotPanel.add(forgotPassword, BorderLayout.EAST);
        
        // 登录按钮 - 水平居中,长度与文本框宽度保持相近
        // 登录按钮 - 使用buttonset创建,水平居中,长度与文本框宽度保持相近
        JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
        buttonPanel.setBackground(Color.WHITE);
        buttonPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 50));
        
        loginButton = new JButton("登录");
        loginButton.setBackground(THEME_COLOR);
        loginButton.setForeground(Color.WHITE);
        // 使用buttonset创建登录按钮,使用主题色
        loginButton = buttonset.createStyledButton("登录", THEME_COLOR);
        loginButton.setFont(new Font("PingFang SC", Font.BOLD, 15));
        // 设置登录按钮长度接近文本框宽度
        loginButton.setPreferredSize(new Dimension(300, 48));
        loginButton.setBorderPainted(false);
        loginButton.setFocusPainted(false);
        loginButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
        // 鼠标悬停效果
        loginButton.addMouseListener(new MouseAdapter() {
            public void mouseEntered(MouseEvent e) {
                loginButton.setBackground(THEME_HOVER_COLOR);
            }
            public void mouseExited(MouseEvent e) {
                loginButton.setBackground(THEME_COLOR);
            }
        });
        loginButton.setMinimumSize(new Dimension(300, 48));
        loginButton.setMaximumSize(new Dimension(300, 48));
        
        buttonPanel.add(loginButton);
        
        // 注册按钮 - 更明显的注册入口
        JPanel registerButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
        registerButtonPanel.setBackground(Color.WHITE);
        registerButtonPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 45));
        registerButton = new JButton("注册新账户");
        registerButton.setBackground(Color.WHITE);
        registerButton.setForeground(THEME_COLOR);
        registerButton.setFont(new Font("PingFang SC", Font.BOLD, 14));
        registerButton.setPreferredSize(new Dimension(180, 42));
        registerButton.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(THEME_COLOR),
            BorderFactory.createEmptyBorder(5, 15, 5, 15)
        ));
        registerButton.setFocusPainted(false);
        registerButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
        // 注册按钮悬停效果
        registerButton.addMouseListener(new MouseAdapter() {
            public void mouseEntered(MouseEvent e) {
                registerButton.setBackground(new Color(240, 250, 240));
            }
            public void mouseExited(MouseEvent e) {
                registerButton.setBackground(Color.WHITE);
            }
        });
        registerButtonPanel.add(registerButton);
        // 注册链接(保留原有的文本链接)
        JPanel signupPanel = new JPanel();
        signupPanel.setBackground(Color.WHITE);
        noAccountLabel = new JLabel("还没有账户? ");
        noAccountLabel.setFont(new Font("PingFang SC", Font.PLAIN, 12));
        noAccountLabel.setForeground(new Color(120, 120, 120));
        signupLink = new JLabel("立即注册");
        signupLink.setFont(new Font("PingFang SC", Font.BOLD, 12));
        signupLink.setForeground(THEME_COLOR);
        signupLink.setCursor(new Cursor(Cursor.HAND_CURSOR));
        signupPanel.add(noAccountLabel);
        signupPanel.add(signupLink);
        // 组装表单
    formPanel.add(Box.createRigidArea(new Dimension(0, 15)));
        formPanel.add(usernameLabel);
@@ -308,26 +249,33 @@
        formPanel.add(rememberForgotPanel);
        formPanel.add(Box.createRigidArea(new Dimension(0, 20)));
        formPanel.add(buttonPanel); // 登录按钮
        formPanel.add(Box.createRigidArea(new Dimension(0, 15)));
        formPanel.add(registerButtonPanel); // 注册按钮
        formPanel.add(Box.createRigidArea(new Dimension(0, 15)));
        formPanel.add(signupPanel); // 保留原有的注册链接
        
        return formPanel;
    }
    private JPanel createAppInfoPanel() {
        JPanel appInfoPanel = new JPanel();
        appInfoPanel.setBackground(Color.WHITE);
        appInfoPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0));
        appInfoLabel = new JLabel(
            getTranslationValue(currentLanguageCode, "app_info", "智能割草系统 © 2023")
        );
        appInfoLabel.setFont(new Font("PingFang SC", Font.PLAIN, 10));
        appInfoLabel.setForeground(new Color(150, 150, 150));
        appInfoPanel.add(appInfoLabel);
    private JPanel createBottomPanel() {
        JPanel bottomPanel = new JPanel();
        bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
        bottomPanel.setBackground(Color.WHITE);
        
        return appInfoPanel;
        // 注册链接(放到页面最下方)
        JPanel signupPanel = new JPanel();
        signupPanel.setBackground(Color.WHITE);
        noAccountLabel = new JLabel("还没有账户? ");
        noAccountLabel.setFont(new Font("PingFang SC", Font.PLAIN, 12));
        noAccountLabel.setForeground(new Color(120, 120, 120));
        signupLink = new JLabel("立即注册");
        signupLink.setFont(new Font("PingFang SC", Font.BOLD, 12));
        signupLink.setForeground(THEME_COLOR);
        signupLink.setCursor(new Cursor(Cursor.HAND_CURSOR));
        signupPanel.add(noAccountLabel);
        signupPanel.add(signupLink);
        signupPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0));
        // 注册链接放在最底部
        bottomPanel.add(signupPanel);
        return bottomPanel;
    }
    private void setupEventHandlers() {
@@ -356,9 +304,6 @@
                openRegistrationWindow();
            }
        });
        // 注册按钮点击事件 - 打开注册窗口
        registerButton.addActionListener(e -> openRegistrationWindow());
    }
    private void updateLanguage(String language) {
@@ -375,10 +320,6 @@
            loginButton.setText(getTranslationValue(langCode, "login_button", loginButton.getText()));
            noAccountLabel.setText(getTranslationValue(langCode, "no_account", noAccountLabel.getText()));
            signupLink.setText(getTranslationValue(langCode, "sign_up", signupLink.getText()));
            appInfoLabel.setText(getTranslationValue(langCode, "app_info", appInfoLabel.getText()));
            // 更新注册按钮文本
            registerButton.setText(getTranslationValue(langCode, "register_button", registerButton.getText()));
            // 更新窗口标题
            setTitle(getTranslationValue(langCode, "window_title", getTitle()));
@@ -607,8 +548,6 @@
    }
    public static void launchMainApp() {
        System.out.println("准备打开主应用程序...");
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
@@ -625,13 +564,10 @@
                mainFrame.setLocationRelativeTo(null);
                mainFrame.setVisible(true);
                System.out.println("主应用程序已启动");
                // 启动后连接MQTT
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        System.out.println("正在连接MQTT服务器...");
                        Client.lianjiemqqt();
                    }
                }).start();
@@ -678,10 +614,6 @@
            UDPServer.startAsync();//启动数据接收线程
            
            // 显示初始数据
            System.out.println("初始用户名: " + UserChuShiHua.getProperty("userName"));
            System.out.println("初始密码: " + UserChuShiHua.getProperty("password"));
            // 启动登录界面(自动登录逻辑在 loadUserPreferences 中处理)
            EventQueue.invokeLater(() -> {
                try {