zhitong.yu
2025-02-06 b8422a40b61a308d102af1e4d9cea24fa461e163
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
package cloud.tianai.captcha.demo;
 
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatLightLaf;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
 
import javax.swing.*;
import java.awt.*;
 
 
@Slf4j
@Controller
@SpringBootApplication
public class TianaiCaptchaDemoApplication {
 
    public static void main(String[] args) throws UnsupportedLookAndFeelException {
        // 初始化皮肤
        FlatLightLaf.install();
        UIManager.setLookAndFeel( new FlatDarkLaf());
        // 初始化窗口
        JFrame jFrame = new JFrame("验证码服务");
        // 设置大小
        jFrame.setSize(500, 500);
        // 关闭窗口后退出
        jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        // 设置居中
        jFrame.setLocationRelativeTo(null);
 
        // 设置图标
        // 示例:正确加载资源
        ImageIcon icon = new ImageIcon(TianaiCaptchaDemoApplication.class.getResource("/images/icon.png"));
        jFrame.setIconImage(icon.getImage());
 
        // 设置元素
        JPanel jPanel = new JPanel(new BorderLayout());
        jPanel.add(new JLabel("服务已启动", JLabel.CENTER), BorderLayout.CENTER);
        jFrame.getContentPane().add(jPanel);
        // 显示窗口
        jFrame.setVisible(true);
        extracted(args);
    }
 
    private static void extracted(String[] args) {
        SpringApplication.run(TianaiCaptchaDemoApplication.class, args);
    }
 
}