forked from Unidata/netcdf-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToolsSplashScreen.java
More file actions
87 lines (70 loc) · 2.2 KB
/
Copy pathToolsSplashScreen.java
File metadata and controls
87 lines (70 loc) · 2.2 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
/*
* Copyright (c) 1998-2025 University Corporation for Atmospheric Research/Unidata
* See LICENSE for license information.
*/
package ucar.nc2.ui;
import ucar.ui.util.Resource;
import java.awt.Dimension;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.lang.invoke.MethodHandles;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JWindow;
/**
*
*/
public class ToolsSplashScreen extends JWindow {
private static final org.slf4j.Logger logger =
org.slf4j.LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static ToolsSplashScreen instance;
/**
*
*/
public static ToolsSplashScreen getSharedInstance() {
if (instance == null) {
instance = new ToolsSplashScreen();
}
return instance;
}
/**
*
*/
private ToolsSplashScreen() {
Image image = Resource.getImage("/resources/ui/pix/ring2.jpg");
if (image != null) {
ImageIcon icon = new ImageIcon(image);
JLabel iconLabel = new JLabel(icon);
getContentPane().add(iconLabel);
pack();
int width = icon.getIconWidth();
int height = icon.getIconHeight();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Point location;
if (gc != null) {
Rectangle gcrect = gc.getBounds();
location = new Point(gcrect.x + gcrect.width / 2 - (width / 2), gcrect.y + gcrect.height / 2 - (height / 2));
} else {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
location = new Point(screenSize.width / 2 - (width / 2), screenSize.height / 2 - (height / 2));
}
setLocation(location);
// Any click on the window hides it.
addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
setVisible(false);
}
});
}
}
}