-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCongratulations.java
More file actions
50 lines (39 loc) · 1.17 KB
/
Congratulations.java
File metadata and controls
50 lines (39 loc) · 1.17 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
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Congratulations extends JFrame{
private static int WIDTH = 440;
private static int HEIGHT = 302;
public static void main(String[] args){
Congratulations test = new Congratulations();
}
public Congratulations(){
Container pane = getContentPane();
ImageIcon image = null;
try {
image = new ImageIcon(ImageIO.read(new File("images/congratulations.png")));
}
catch (IOException e){
}
catch (IllegalArgumentException e){
}
JLabel label = new JLabel("");
label.setIcon(image);
pane.add(label);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Point middle = new Point(screenSize.width / 2, screenSize.height / 2);
Point newLocation = new Point(middle.x - (WIDTH/2),
middle.y - (HEIGHT/2));
setLocation(newLocation);
setVisible(true);
setSize(WIDTH, HEIGHT);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}