-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplashScreen.java
More file actions
87 lines (75 loc) · 2.89 KB
/
SplashScreen.java
File metadata and controls
87 lines (75 loc) · 2.89 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
//****************************************************************************
// Assignment: Program (Project)
//
// Authors and matrix number: Azrie Bin Joe@ Abdullah (46380)
// Norhaslin binti Naton (48103)
// Mohd Azman Bin Uddin (42217)
//
// Honour code: We pledge that this program represents our own program code.
// We received help from (Mohd Saifuddin and Internet)in understanding and debugging our program.
//****************************************************************************
import java.awt.*;
import javax.swing.*;
import javax.sound.sampled.*;
import java.io.File;
import java.io.IOException;
public class SplashScreen extends JWindow {
private int duration;
public SplashScreen(int d) {
duration = d;
}
// A simple little method to show a title screen in the center
// of the screen for the amount of time given in the constructor
public void showSplash() {
JPanel content = (JPanel)getContentPane();
content.setBackground(Color.white);
// Set the window's bounds, centering the window
int width = 600;
int height =338;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int x = (screen.width-width)/2;
int y = (screen.height-height)/2;
setBounds(x,y,width,height);
// Build the splash screen
JLabel label = new JLabel(new ImageIcon("pic\\LOGAN.gif"));
JLabel copyrt = new JLabel
("LOGAN", JLabel.CENTER);
copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12));
content.add(label, BorderLayout.CENTER);
content.add(copyrt, BorderLayout.SOUTH);
Color oraRed = new Color(156, 20, 20, 255);
content.setBorder(BorderFactory.createLineBorder(oraRed, 3));
// Display it
setVisible(true);
// Wait a little while, maybe while loading resources
try { Thread.sleep(duration); } catch (Exception e) {}
setVisible(false);
}
public void showSplashAndExit() {
showSplash();
System.exit(0);
}
public static void main(String[] args) {
// Throw a nice little title page up on the screen first
SplashScreen splash = new SplashScreen(2500);
try {
// Open an audio input stream.
File soundFile = new File ("sound\\claw.wav");
AudioInputStream audioIn = AudioSystem.getAudioInputStream(soundFile);
// Get a sound clip resource.
Clip clip = AudioSystem.getClip();
// Open audio clip and load samples from the audio input stream.
clip.open(audioIn);
clip.stop();
clip.setFramePosition(0);
clip.start();
} catch (UnsupportedAudioFileException p) {
p.printStackTrace();
} catch (IOException p) {
p.printStackTrace();
} catch (LineUnavailableException p) {
p.printStackTrace();
}
splash.showSplashAndExit();
}
}