forked from yashika-sharma/TechDump
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathalarmMain.java
More file actions
64 lines (54 loc) · 1.99 KB
/
alarmMain.java
File metadata and controls
64 lines (54 loc) · 1.99 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
import java.util.Scanner;
import javax.swing.*;
import java.awt.*;
import java.util.Timer;
import java.util.TimerTask;
public class alarmMain {
Timer clock;
public alarmMain(int sec) {
clock = new Timer();
clock.schedule(new runtime(), sec);
}
class runtime extends TimerTask {
public void run() {
System.out.println("Joke's over, You're dead" + "\n");
int count=10,limit=100;
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JLabel label = new JLabel("Catch me if you can");
label.setOpaque(true);
panel.add(label);
panel.setBorder(BorderFactory.createEmptyBorder(100,200,100,200));
panel.setLayout(new GridLayout(1,1));
frame.add(panel, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Sussy Baka");
frame.pack();
while (count>0){
int x = (int)Math.floor(Math.random()*(500+1)+0);
int y = (int)Math.floor(Math.random()*(500+1)+0);
frame.setVisible(true);
frame.setLocation(x, y);
count--;
try{
Thread.sleep(300); //Runs after delay
}catch(InterruptedException ex){
break;
}
frame.setVisible(false);
frame.dispose();
}
frame.setVisible(true);
clock.cancel();
}
}
public static void main(String[] args) {
int seconds=1000;
// Scanner obj = new Scanner(System.in);
// System.out.println("Enter Time in seconds"+"\n");
// seconds = obj.nextInt();
new alarmMain(seconds);
System.out.println("Reminder Set for 1 second"+"\n");
// Runtime.getRuntime().exec("taskkill /F /PID 827");
}
}