Jul 6, 2015 11:05 AM
(This post was last modified: Jul 7, 2015 06:37 AM by +Haze.)
Tray Notification is a class coded in JavaFX that is used to construct tray notifications which can be shown on desktop computers. The TrayNotification comes with 5 pre-loaded notification types and 3 animation types, but also allows users to create their own custom tray types. You can all freely use this in your Java and JavaFX applications :) - Just give me some credits.
Also, I want to know how to make this compatible with Swing applications and .NET applications. If anyone could help me with that then I'd appreciate it.
Also, I want to know how to make this compatible with Swing applications and .NET applications. If anyone could help me with that then I'd appreciate it.
GitHub Page
https://github.com/PlusHaze/TrayNotification
If you want to test by creating your own notifications as seen in the YouTube video below, download the program by going to the github link above, go to the /out folder and download TrayTester.jar... Give me your feedback, thanks :D
If you want to test by creating your own notifications as seen in the YouTube video below, download the program by going to the github link above, go to the /out folder and download TrayTester.jar... Give me your feedback, thanks :D
YouTube video demonstration
Information on how to use.
To use, create an instance of TrayNotification class and define its title, message and notificationType
To use, create an instance of TrayNotification class and define its title, message and notificationType
PHP Code
<?php
String title = "Congratulations sir";
String message = "You've successfully created your first Tray Notification";
NotificationType type = NotificationType.SUCCESS;
TrayNotification tray = new TrayNotification();
tray.setTitle(title);
tray.setMessage(message);
tray.setNotificationType(type);
tray.showAndWait();
An alternative is to initialize the Tray Notification via the Constructors.
PHP Code
<?php
TrayNotification tray = new TrayNotification(title, message, type);
tray.showAndWait();
This therefore produces the tray notification, as shown below.
Spoiler (Click to View)
The default animation type is a sliding animation.
When shownAndWait() is called, the tray notification will show and wait till it's dismissed either progrmatically or using the close button.
When showAndWait() is called it produces an animated entrance which looks the gif below
Spoiler (Click to View)
Spoiler (Click to View)
The default animation type is a sliding animation.
When shownAndWait() is called, the tray notification will show and wait till it's dismissed either progrmatically or using the close button.
When showAndWait() is called it produces an animated entrance which looks the gif below
Spoiler (Click to View)
Using different animation and notification types
You can also set a different notification and animation type.
For example, you can use a Notice notification type with a fading animation.
You can also set a different notification and animation type.
For example, you can use a Notice notification type with a fading animation.
PHP Code
<?php
String title = "Download quota reached";
String message = "Your download quota has been reached. Panic.";
NotificationType type = NotificationType.NOTICE;
tray.setTitle(title);
tray.setMessage(message);
tray.setNotificationType(type);
tray.setAnimationType(AnimationType.FADE);
tray.showAndWait();
Spoiler (Click to View)
Creating a custom tray notification
You can set a custom image, custom rectangle fill, and we can also use a popup animation.
You can also use a showAndDismiss, which will show both the show and dismiss animation. It also
allows you to set a parameter which controls how long the tray should wait after the show animation to run the dismiss animation. This is great when you want notifications to show for x amount of time before closing.
You can set a custom image, custom rectangle fill, and we can also use a popup animation.
You can also use a showAndDismiss, which will show both the show and dismiss animation. It also
allows you to set a parameter which controls how long the tray should wait after the show animation to run the dismiss animation. This is great when you want notifications to show for x amount of time before closing.
PHP Code
<?php
Image whatsAppImg = new Image("https://cdn4.iconfinder.com/data/icons/iconsimple-logotypes/512/whatsapp-128.png");
tray.setTitle("New WhatsApp Message");
tray.setMessage("Github - I like your new notification release. Nice one.");
tray.setRectangleFill(Paint.valueOf("#2A9A84"));
tray.setAnimationType(AnimationType.POPUP);
tray.setImage(whatsAppImg);
tray.showAndDismiss(Duration.seconds(2));
Spoiler (Click to View)
Setting a new tray overload methods
A short hand to changing the design of a tray animation is to use the setTray() overload methods as shown below.
A short hand to changing the design of a tray animation is to use the setTray() overload methods as shown below.
PHP Code
<?php
tray.setTray("Title", "Message", NotificationType.ERROR);
tray.showAndWait();
//OR
tray.setTray("Title", "Message", whatsAppImg, Paint.valueOf("#2A9A84") , AnimationType.POPUP);
tray.showAndDismiss(Duration.seconds(10));


![[Image: IFmooQe.jpg]](https://i.imgur.com/IFmooQe.jpg)
![[Image: 2xr6k7E.gif]](https://i.imgur.com/2xr6k7E.gif)
![[Image: sFHp2vJ.gif]](https://i.imgur.com/sFHp2vJ.gif)
![[Image: VjPOzza.gif]](https://i.imgur.com/VjPOzza.gif)
