Repository navigation
Expand file tree
/
Copy pathTitleScreen.java
More file actions
48 lines (40 loc) · 1.93 KB
/
Copy pathTitleScreen.java
File metadata and controls
48 lines (40 loc) · 1.93 KB
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
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
public class TitleScreen extends JPanel {
private static final Color BG_COLOR = new Color(15, 20, 35);
private static final Color BORDER_COLOR = new Color(0, 200, 190);
public TitleScreen(Runnable onStartClicked) {
setPreferredSize(new Dimension(1050, 800));
setBackground(BG_COLOR);
setLayout(new GridBagLayout());
JPanel container = new JPanel();
container.setOpaque(false);
container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
// 게임 타이틀 로고
JLabel titleLabel = new JLabel("JavaQuest", SwingConstants.CENTER);
titleLabel.setForeground(Color.WHITE);
titleLabel.setFont(new Font("맑은 고딕", Font.BOLD, 52));
titleLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
JLabel subLabel = new JLabel("프로그래밍 & 지식 모험 RPG", SwingConstants.CENTER);
subLabel.setForeground(BORDER_COLOR);
subLabel.setFont(new Font("맑은 고딕", Font.BOLD, 18));
subLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
// 게임 시작 버튼
JButton startBtn = new JButton("게임 시작");
startBtn.setBackground(new Color(25, 30, 50));
startBtn.setForeground(Color.YELLOW);
startBtn.setFont(new Font("맑은 고딕", Font.BOLD, 22));
startBtn.setBorder(new LineBorder(BORDER_COLOR, 2));
startBtn.setFocusPainted(false);
startBtn.setAlignmentX(Component.CENTER_ALIGNMENT);
startBtn.setMaximumSize(new Dimension(250, 60));
startBtn.addActionListener(e -> onStartClicked.run());
container.add(titleLabel);
container.add(Box.createVerticalStrut(10));
container.add(subLabel);
container.add(Box.createVerticalStrut(60));
container.add(startBtn);
add(container);
}
}