-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathGameLauncher.java
More file actions
120 lines (109 loc) · 3.23 KB
/
GameLauncher.java
File metadata and controls
120 lines (109 loc) · 3.23 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
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;
import javax.swing.UIManager;
public class GameLauncher extends JWindow {
final int MAX_PROGRESS = 100;
final int TIMER_DELAY = 100;
JProgressBar progressBar = new JProgressBar();
private boolean isVisible = false;
private JPanel contentPane;
JLabel lblGamerZone = new JLabel("Gamer Zone-2016");
Timer timer ;
int color = 1;
int currentProgress = 1;
/**
* Launch the application.
*/
public static void main(String[] args) {
GameLauncher frame = new GameLauncher();
frame.setVisible(true);
frame.animation();
}
private void animation(){
// For Delay in Swing
// We Need Timer Class
ActionListener listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
progressBar.setValue(currentProgress);
currentProgress++;
if(currentProgress>=MAX_PROGRESS){
timer.stop();
GameLauncher.this.setVisible(false);
GameLauncher.this.dispose();
MainScreen mainScreen = new MainScreen();
mainScreen.setVisible(true);
mainScreen.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
lblGamerZone.setVisible(isVisible);
isVisible = !isVisible;
if(isVisible){
if(color>5){
color=1;
}
switch (color){
case 1 :
lblGamerZone.setForeground(Color.RED);
break;
case 2 :
lblGamerZone.setForeground(Color.GREEN);
break;
case 3 :
lblGamerZone.setForeground(Color.BLUE);
break;
case 4 :
lblGamerZone.setForeground(Color.CYAN);
break;
case 5 :
lblGamerZone.setForeground(Color.ORANGE);
break;
default:
lblGamerZone.setForeground(Color.BLACK);
}
color++;
}
}
};
// Now this timer will call ActionListener in Every 100 ms Interval
timer = new Timer(TIMER_DELAY,listener);
timer.start();
}
/**
* Create the frame.
*/
public GameLauncher() {
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 517, 459);
contentPane = new JPanel();
contentPane.setBackground(UIManager.getColor("TextArea.selectionBackground"));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(null);
setContentPane(contentPane);
JLabel mainLbl = new JLabel("");
mainLbl.setIcon(new ImageIcon(GameLauncher.class.getResource("main.gif")));
mainLbl.setBounds(19, 19, 476, 302);
contentPane.add(mainLbl);
lblGamerZone.setHorizontalAlignment(SwingConstants.CENTER);
lblGamerZone.setFont(new Font("Lucida Grande", Font.BOLD, 24));
lblGamerZone.setBounds(130, 333, 287, 38);
contentPane.add(lblGamerZone);
progressBar.setBackground(Color.WHITE);
progressBar.setForeground(Color.GREEN);
progressBar.setFont(new Font("Lucida Grande", Font.BOLD, 22));
progressBar.setStringPainted(true);
progressBar.setBounds(19, 383, 476, 38);
contentPane.add(progressBar);
}
}