How to create a notification app icon badge in JavaFX's taskbar icon? Just like Teams or Slack that has a badge on their icon when a notification comes. Like this image:
Asked
Active
Viewed 1,020 times
0
-
IntelliJ offers a feature to add the programs icon image on building it, File -> Project Structure -> Artifacts + JavaFX – Joe Jul 01 '19 at 05:04
-
1https://stackoverflow.com/questions/20237050/how-to-change-default-java-logo-exe-icon-on-the-taskbar-in-javafx – Kenneth Clark Jul 01 '19 at 05:20
-
No I mean, like this one https://d2slcw3kip6qmk.cloudfront.net/marketing/pages/chart/slack/notification-icon.png – Newbie Coder Jul 01 '19 at 05:57
1 Answers
4
There is no specific way to define icons with badges for JavaFX. However, you can change the icon of your application based on whether you have notifications or not:
// define two (or more) different icons
Image iconWithNoNotifications = new Image(this.getClass().getResourceAsStream("app_icon.png"));
Image iconWithNotifications = new Image(this.getClass().getResourceAsStream("app_icon_with_notification.png"));
// change the icon when the notifications count changes
primaryStage.getIcons().add(nNotifications == 0 ? iconWithNoNotifications : iconWithNotifications);

Miss Chanandler Bong
- 4,081
- 10
- 26
- 36