5、任务栏图标设置
我们可以使用TrayIcon类来表示一个任务栏的图标
SystemTray tray = SystemTray.getSystemTray();
this.trayIcon = new TrayIcon(trayIconImage, "多线程下载工具", this.popupMenu);
this.trayIcon.setToolTip("多线程下载工具");
tray.add(this.trayIcon);
由于TrayIcon只支持使用awt的PopupMenu作为鼠标右键弹出菜单,因此我们在这里没有使用Swing的JPopupMenu作为弹出菜单。
加入任务栏后的效果如图