■ ■ ■ ■ ■ ■ ■
vucsa-client/src/main/java/com/warxim/vucsa/client/gui/GuiApplication.java
| skipped 26 lines |
27 | 27 | | import javafx.scene.Scene; |
28 | 28 | | import javafx.stage.Stage; |
29 | 29 | | |
| 30 | + | import javax.imageio.ImageIO; |
| 31 | + | import java.awt.Taskbar; |
| 32 | + | import java.util.logging.Level; |
| 33 | + | import java.util.logging.Logger; |
| 34 | + | |
30 | 35 | | /** |
31 | 36 | | * Client GUI application. |
32 | 37 | | * <p>Starts Vulnerable Client GUI.</p> |
| skipped 1 lines |
34 | 39 | | public class GuiApplication extends Application { |
35 | 40 | | @Override |
36 | 41 | | public void start(Stage stage) throws Exception { |
| 42 | + | setupIcons(stage); |
| 43 | + | |
37 | 44 | | Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA); |
38 | 45 | | StyleManager.getInstance().addUserAgentStylesheet(getClass().getResource(GuiConstant.MAIN_CSS_PATH).toString()); |
39 | 46 | | |
| skipped 7 lines |
47 | 54 | | |
48 | 55 | | var scene = new Scene(root); |
49 | 56 | | stage.setTitle("VuCSA Client v" + Constant.VERSION); |
50 | | - | stage.getIcons().add(GuiBundle.getInstance().getLogo()); |
51 | 57 | | stage.setWidth(1200); |
52 | 58 | | stage.setHeight(900); |
53 | 59 | | stage.setScene(scene); |
| skipped 12 lines |
66 | 72 | | |
67 | 73 | | Bundle.getInstance().destroy(); |
68 | 74 | | GuiBundle.getInstance().destroy(); |
| 75 | + | } |
| 76 | + | |
| 77 | + | /** |
| 78 | + | * Sets up icons for the application |
| 79 | + | */ |
| 80 | + | protected void setupIcons(Stage stage) { |
| 81 | + | // Set stage icons (WIN, LINUX) |
| 82 | + | stage.getIcons().add(GuiBundle.getInstance().getLogo()); |
| 83 | + | |
| 84 | + | // Little workaround to set icons for macOS taskbar using AWT |
| 85 | + | try { |
| 86 | + | if (!Taskbar.isTaskbarSupported()) { |
| 87 | + | return; |
| 88 | + | } |
| 89 | + | var iconImage = ImageIO.read(getClass().getResourceAsStream(GuiConstant.ICON_PATH)); |
| 90 | + | var taskbar = Taskbar.getTaskbar(); |
| 91 | + | taskbar.setIconImage(iconImage); |
| 92 | + | } catch (Exception e) { |
| 93 | + | Logger.getGlobal().log(Level.SEVERE, "Could not set taskbar icon!", e); |
| 94 | + | } |
69 | 95 | | } |
70 | 96 | | } |
71 | 97 | | |