-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplashScreen.java
More file actions
68 lines (57 loc) · 1.77 KB
/
SplashScreen.java
File metadata and controls
68 lines (57 loc) · 1.77 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
import java.awt.*;
import java.awt.event.ActionListener;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class SplashScreen extends JWindow {
private int showtime;
private static Timer timer;
private static int counter = 0;
private static JProgressBar progress = new JProgressBar();
public SplashScreen(int d)
{
showtime = d;
}
public void exhibitSplash() throws Exception {
JPanel Screen = (JPanel) getContentPane();
Screen.setBackground(new Color(255,245,204));
Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();//set to the center of the screen
setBounds((sc.width-425)/2, (sc.height-300)/2, 425, 250);
JLabel welcome = new JLabel(new ImageIcon("newlogo.png"));
EmptyBorder border = new EmptyBorder(15, 0, 0, 0);
welcome.setBorder(border);
Image image = ImageIO.read(new File("loading.png"));
Image scaledImage = image.getScaledInstance(70, 70, Image.SCALE_SMOOTH);
JLabel labelpng = new JLabel(new ImageIcon(scaledImage));
progress.setMaximum(50);
Screen.add(progress, BorderLayout.SOUTH);
LoadSplash();
Screen.add(welcome, BorderLayout.NORTH);
Screen.add(labelpng, BorderLayout.CENTER);
Screen.setBorder(BorderFactory.createLineBorder(new Color(251,191,105), 5));
setVisible(true);
try {
Thread.sleep(showtime);
} catch (Exception e) {
}
setVisible(false);
}
public void LoadSplash() {
ActionListener al = new ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
progress.setValue(++counter);
if (counter == 600) {
timer.stop();
setVisible(false);
return;
}
}
};
timer = new Timer(100, al);
timer.start();
}
public void VisiblethenDisappear() throws Exception {
exhibitSplash();
}
}