-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
41 lines (39 loc) · 1.29 KB
/
Main.java
File metadata and controls
41 lines (39 loc) · 1.29 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
import java.awt.*;
import javax.swing.*;
public class Main extends JWindow {
Image splashScreen;
ImageIcon imageIcon;
public Main() {
splashScreen = Toolkit.getDefaultToolkit().getImage("C:\\Users\\kesha\\OneDrive\\Desktop\\Icons\\sp\\splash2.png");
// Create ImageIcon from Image
imageIcon = new ImageIcon(splashScreen);
// Set JWindow size from image size
setSize(700,700);
// Get current screen size
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
// Get x coordinate on screen for make JWindow locate at center
int x = (screenSize.width-getSize().width)/2;
// Get y coordinate on screen for make JWindow locate at center
int y = (screenSize.height-getSize().height)/2;
// Set new location for JWindow
setLocation(x,y);
// Make JWindow visible
setVisible(true);
}
// Paint image onto JWindow
public void paint(Graphics g) {
super.paint(g);
g.drawImage(splashScreen, 0, 0, this);
}
public static void main(String[]args) {
Main splash = new Main();
try {
// Make JWindow appear for 5 seconds before disappear
Thread.sleep(5000);
splash.dispose();
} catch(Exception e) {
e.printStackTrace();
}
new Frame();
}
}