Skip to content

Commit 530d64e

Browse files
author
Denys Zaiats
committed
[master] - catching exceptions during validation for Retina display
1 parent aa04d4f commit 530d64e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/main/java/util/general/SystemHelper.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@
66
public class SystemHelper {
77
public static boolean isRetinaDisplay(Graphics2D g) {
88
boolean isRetina = false;
9-
GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
10-
119
try {
12-
Field field = graphicsDevice.getClass().getDeclaredField("scale");
13-
if (field != null) {
14-
field.setAccessible(true);
15-
Object scale = field.get(graphicsDevice);
16-
if (scale instanceof Integer && ((Integer) scale).intValue() == 2) {
17-
isRetina = true;
10+
GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
11+
12+
try {
13+
Field field = graphicsDevice.getClass().getDeclaredField("scale");
14+
if (field != null) {
15+
field.setAccessible(true);
16+
Object scale = field.get(graphicsDevice);
17+
if (scale instanceof Integer && ((Integer) scale).intValue() == 2) {
18+
isRetina = true;
19+
}
1820
}
21+
} catch (Exception e) {
22+
e.printStackTrace();
1923
}
20-
} catch (Exception e) {
24+
}catch (Exception e){
2125
e.printStackTrace();
2226
}
2327
return isRetina;

0 commit comments

Comments
 (0)