import java awt import java awt image BufferedImage import java awt ev

 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
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Alarm {
public static void main(String[] args) {
final TrayIcon trayIcon;
if(SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit().getImage("tray.gif");
ActionListener exitListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
};
PopupMenu menu = new PopupMenu();
MenuItem exitItem = new MenuItem("Exit...");
exitItem.addActionListener(exitListener);
menu.add(exitItem);
trayIcon = new TrayIcon(image, "Alarm", menu);
trayIcon.setImageAutoSize(false);
try {
tray.add(trayIcon);
} catch (AWTException e) {
e.printStackTrace();
}
if(args.length == 1) {
(new TimerThread(trayIcon, Integer.valueOf(args[0]))).run();
} else {
(new TimerThread(trayIcon, 5)).run();
}
}
}
}