forked from JustinSDK/JavaSE6Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystemTrayDemo2.java
More file actions
26 lines (24 loc) · 899 Bytes
/
SystemTrayDemo2.java
File metadata and controls
26 lines (24 loc) · 899 Bytes
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
package onlyfun.caterpillar;
import java.awt.*;
import javax.swing.*;
public class SystemTrayDemo2 {
public static void main(String[] args) {
if(SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit()
.getImage("musical_note_smile.gif");
PopupMenu popup = new PopupMenu();
MenuItem item = new MenuItem("開啟JNotePad 1.0");
popup.add(item);
TrayIcon trayIcon = new TrayIcon(image, "JNotePad 1.0", popup);
try {
tray.add(trayIcon);
} catch (AWTException e) {
System.err.println("無法加入系統工具列圖示");
e.printStackTrace();
}
} else {
System.err.println("無法取得系統工具列");
}
}
}