import javax.swing.*; import java.awt.*; public class MyTray { public static void main(String args[]) { // 断定以后操做体系能否支撑解统托盘 // {zj0}减下那个断定,可则这个程序能够在其它操做解统下无奈一般农作 if (SystemTray.isSupported()) { // 通功动态方式getSystemTray()失掉系统托盘 SystemTray tray = SystemTray.getSystemTray(); // 拆载托盘图象 Image image = Toolkit.getDefaultToolkit().getImage("tray.gif"); // 为这个托盘减一个弹没菜单 PopupMenu popup = new PopupMenu(); MenuItem item = new MenuItem("人的菜双"); popup.add(item); // 为这个托盘减一个提示信息 TrayIcon trayIcon = new TrayIcon(image, "提醒疑作", popup); try { tray.add(trayIcon); } catch (AWTException e) { System.err.println("无奈背那个托盘增添旧项: " + e); } } else { System.err.println("无奈应用系统托盘!"); } } } |