-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMyIntroScreen.java
More file actions
100 lines (83 loc) · 2.43 KB
/
MyIntroScreen.java
File metadata and controls
100 lines (83 loc) · 2.43 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
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JWindow;
import javax.swing.Timer;
import javax.swing.border.EmptyBorder;
import jaco.mp3.player.MP3Player;
public class MyIntroScreen extends JWindow {
JLabel photo = new JLabel(""); // Instance Variable
JLabel lblGameOn = new JLabel("Game On");
JProgressBar progressBar = new JProgressBar();
Timer timer ;
private final int DELAY = 100;
private boolean isVisible = false;
private int counter = 1;
MP3Player player ;
private void playSong(){
player = new MP3Player(MyIntroScreen.class.getResource("S.mp3"));
player.play();
}
private void animation(){
ActionListener action = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
lblGameOn.setVisible(isVisible);
isVisible = !isVisible;
progressBar.setValue(counter);
if(counter>=100){
timer.stop();
player.stop();
MyIntroScreen.this.setVisible(false);
LoginFrame frame = new LoginFrame();
frame.setVisible(true);
}
counter++;
}
};
timer = new Timer(DELAY,action);
timer.start();
}
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
MyIntroScreen frame = new MyIntroScreen();
frame.setVisible(true);
frame.animation();
frame.playSong();
}
/**
* Create the frame.
*/
public MyIntroScreen() {
Icon icon = new ImageIcon(MyIntroScreen.class.getResource("intro.gif"));
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 358);
contentPane = new JPanel();
contentPane.setBackground(Color.CYAN);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
// Local Variable
photo.setIcon(icon);
photo.setBounds(6, 6, 438, 252);
contentPane.add(photo);
lblGameOn.setFont(new Font("Lucida Grande", Font.BOLD, 28));
lblGameOn.setBounds(161, 270, 149, 41);
contentPane.add(lblGameOn);
progressBar.setFont(new Font("Lucida Grande", Font.BOLD, 24));
progressBar.setStringPainted(true);
progressBar.setBounds(6, 310, 438, 20);
contentPane.add(progressBar);
}
}