class EasyBookmarkApp : App(MainView::class) { override fun start(stage: Stage) { super.start(stage) stage.hide() Platform.setImplicitExit(false) SwingUtilities.invokeLater { this.addAppToTray() } } private fun addAppToTray() { try { Toolkit.getDefaultToolkit() if (!SystemTray.isSupported()) { println("Creating system tray not supported") Platform.exit() } val tray = SystemTray.getSystemTray() val trayIcon = TrayIcon(AppSettings.icon) setupMenu(tray, trayIcon) tray.add(trayIcon) } catch (e: AWTException) { println("Unable to init system tray") e.printStackTrace() } catch (e: IOException) { println("Unable to init system tray") e.printStackTrace() } }