-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameSplash.java
More file actions
88 lines (74 loc) · 2.15 KB
/
GameSplash.java
File metadata and controls
88 lines (74 loc) · 2.15 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
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
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JWindow;
import javax.swing.SwingConstants;
import javax.swing.Timer;
import javax.swing.border.EmptyBorder;
public class GameSplash extends JWindow {
private JPanel contentPane;
JProgressBar progressBar = new JProgressBar();
int progressvalue = 0;
Timer timer;
boolean isvisible = true;
JLabel lblNewLabel = new JLabel("Tic - Tac -Toe");
/**
* Launch the application.
*/
public static void main(String[] args) {
GameSplash frame = new GameSplash();
frame.setVisible(true);
frame.doanimation();
}
/**
* Create the frame.
*
* @return
*/
public void doanimation() {
timer = new Timer(50, new ActionListener() {
Random r = new Random();
@Override
public void actionPerformed(ActionEvent e) {
lblNewLabel.setVisible(isvisible);
if (progressvalue >= 100) {
timer.stop();
GameSplash.this.setVisible(false);
GameSplash.this.dispose();
TicTacToe toe = new TicTacToe();
toe.setVisible(true);
}
lblNewLabel.setForeground(new Color(r.nextInt(255), r.nextInt(100), r.nextInt(155)));
progressvalue++;
progressBar.setValue(progressvalue);
isvisible = !isvisible;
}
});
timer.start();
}
public GameSplash() {
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBackground(Color.CYAN);
contentPane.setForeground(Color.WHITE);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(null);
setContentPane(contentPane);
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 26));
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setBounds(110, 77, 223, 75);
contentPane.add(lblNewLabel);
progressBar.setStringPainted(true);
progressBar.setBackground(Color.WHITE);
progressBar.setForeground(Color.GREEN);
progressBar.setBounds(10, 212, 414, 22);
contentPane.add(progressBar);
}
}