-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
64 lines (50 loc) · 1.59 KB
/
Main.java
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
package com.reflection;
import javax.swing.*;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
public class Main {
// static variables
public static int WAIT = 20 * 60 * 1000;
public static int SHOW = 40 * 1000;
private Display display;
private java.util.Timer timer;
public Main() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
display = new Display();
}
});
timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
display.start();
}
});
}
}, WAIT, WAIT);
}
public static void main(String[] args) {
new Main();
}
public static void shutdown() {
String shutdownCommand = "";
String operatingSystem = System.getProperty("os.name").toLowerCase();
if (operatingSystem.contains("nix") || operatingSystem.contains("mac")) {
shutdownCommand = "shutdown -h now";
} else if (operatingSystem.contains("win")) {
shutdownCommand = "shutdown.exe -s -t 0";
}
if (shutdownCommand.length() > 0) {
try {
Runtime.getRuntime().exec(shutdownCommand);
} catch (IOException e) {
System.err.println("Could not issue shutdown command");
}
}
System.exit(0);
}
}