826220679@qq.com
2025-08-07 4d6cd980c5c69e4d9d150669c89734642297e0cd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package window;
 
import java.awt.*;
import java.sql.Connection;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.util.ResourceBundle;
 
public class WindowFactory {    
 
    @SuppressWarnings("unused")
    private static JPanel createWelcomePanel(ResourceBundle messages, Connection conn) {
        JPanel panel = new JPanel(new BorderLayout());
        
        JLabel titleLabel = new JLabel(messages.getString("APP_NAME"), SwingConstants.CENTER);
        titleLabel.setFont(new Font("΢ÈíÑźÚ", Font.BOLD, 36));
        titleLabel.setForeground(new Color(0, 120, 215));
        titleLabel.setBorder(new EmptyBorder(50, 0, 20, 0));
        
        JLabel subtitleLabel = new JLabel(messages.getString("WELCOME_MSG"), SwingConstants.CENTER);
        subtitleLabel.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 24));
        subtitleLabel.setForeground(new Color(100, 100, 100));
        
        JPanel infoPanel = new JPanel(new GridLayout(0, 1, 10, 10));
        infoPanel.setBorder(new EmptyBorder(30, 100, 30, 100));
        
        infoPanel.add(createInfoLabel(messages.getString("SYSTEM_STATUS"), 
                                     messages.getString("RUNNING_NORMAL"), 
                                     Color.GREEN.darker()));
        
        infoPanel.add(createInfoLabel(messages.getString("DB_CONNECTION"), 
                                     conn != null ? messages.getString("CONNECTED") : messages.getString("DISCONNECTED"), 
                                     conn != null ? Color.GREEN.darker() : Color.RED));
        
        try {
            if (conn != null) {
                try (java.sql.Statement stmt = conn.createStatement();
                     java.sql.ResultSet rs = stmt.executeQuery("SELECT VERSION()")) {
                    if (rs.next()) {
                        infoPanel.add(createInfoLabel(messages.getString("DB_VERSION"), 
                                     rs.getString(1), 
                                     Color.BLUE));
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        infoPanel.add(createInfoLabel(messages.getString("CURRENT_USER"), 
                     messages.getString("ADMIN"), 
                     Color.BLUE));
        
        infoPanel.add(createInfoLabel(messages.getString("SYSTEM_TIME"), 
                     new java.util.Date().toString(), 
                     Color.BLUE));
        
        panel.add(titleLabel, BorderLayout.NORTH);
        panel.add(subtitleLabel, BorderLayout.CENTER);
        panel.add(infoPanel, BorderLayout.SOUTH);
        
        return panel;
    }
 
    private static JLabel createInfoLabel(String title, String value, Color color) {
        JLabel label = new JLabel("<html><b>" + title + ":</b> " + value + "</html>");
        label.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 18));
        label.setForeground(color);
        return label;
    }
    
    public static JInternalFrame createWelcomeFrame(ResourceBundle messages, Connection conn) {
        return new WelcomeFrame(messages, conn);
    }
 
    public static JInternalFrame createFunctionFrame(String title) {
        JInternalFrame frame = new JInternalFrame(
                title, true, true, true, true);
        frame.setSize(600, 400);
        frame.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
        frame.setLocation(0, 0);
        
        frame.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
        
        frame.setMaximizable(true);
        frame.setIconifiable(true);
        frame.setClosable(true);
        return frame;
    }
}