package pro.simpleproject.core.tray;

public class TrayBuilder {

}

@@ -35,34 +35,1547 @@
 y;%0A%0A
-public class TrayBuilder %7B
+import java.awt.Image;%0Aimport java.awt.MenuItem;%0Aimport java.awt.PopupMenu;%0Aimport java.awt.SystemTray;%0Aimport java.awt.Toolkit;%0Aimport java.awt.TrayIcon;%0Aimport java.io.File;%0A%0Aimport javax.imageio.ImageIO;%0A%0Aimport javafx.application.Platform;%0Aimport pro.simpleproject.core.start.Start;%0A%0Apublic class TrayBuilder %7B%0A%0A%09private static TrayIcon trayIcon;%0A%0A%09public static boolean build() %7B%0A%09%09Toolkit.getDefaultToolkit();%0A%09%09if (!SystemTray.isSupported()) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%09%09SystemTray tray = SystemTray.getSystemTray();%0A%09%09try %7B%0A%09%09%09File f = new File(%22%22);%0A%09%09%09Image image = ImageIO.read(f);%0A%09%09%09trayIcon = new TrayIcon(image);%0A%09%09%09trayIcon.addActionListener(e -%3E %7B%0A%09%09%09%09Platform.runLater(() -%3E %7B%0A%09%09%09%09%09showStage();%0A%09%09%09%09%7D);%0A%09%09%09%7D);%0A%09%09%09MenuItem openItem = new MenuItem(%22Show%22);%0A%09%09%09openItem.addActionListener(event -%3E %7B%0A%09%09%09%09Platform.runLater(() -%3E %7B%0A%09%09%09%09%09showStage();%0A%09%09%09%09%7D);%0A%09%09%09%7D);%0A%09%09%09MenuItem exitItem = new MenuItem(%22Exit%22);%0A%09%09%09exitItem.addActionListener(e -%3E %7B%0A%09%09%09%09Platform.exit();%0A%09%09%09%09tray.remove(trayIcon);%0A%09%09%09%7D);%0A%09%09%09PopupMenu popup = new PopupMenu();%0A%09%09%09popup.add(openItem);%0A%09%09%09popup.addSeparator();%0A%09%09%09popup.add(exitItem);%0A%09%09%09trayIcon.setPopupMenu(popup);%0A%09%09%09tray.add(trayIcon);%0A%09%09%09return true;%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%09return false;%0A%09%7D%0A%0A%09private static void showStage() %7B%0A%09%09if (Start.getStage() != null) %7B%0A%09%09%09Start.getStage().show();%0A%09%09%09Start.getStage().toFront();%0A%09%09%7D%0A%09%7D%0A%0A%09public static void close() %7B%0A%09%09if (trayIcon != null) %7B%0A%09%09%09SystemTray tray = SystemTray.getSystemTray();%0A%09%09%09tray.remove(trayIcon);%0A%09%09%7D%0A%09%7D
 %0A%0A%7D%0A

Update TrayBuilder.java