Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Animated Tray Notification | Fully Customizabe | JavaFX

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.



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





YouTube video demonstration






Information on how to use.

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)



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.

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(); 




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.

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.

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)); 
That looks very nice Haze. I can't wait to see it be used in literally every Java application on HF.
I do suggest that the slide-in animation is a bit strange because it goes all the way to the center of the screen.
That looks really great! Nice work you have done there.
May I suggest notification lengths.

You could have it use TimeUnit and stuff or maybe a enum like NotificationTime.NORMAL
(Jul 6, 2015 11:46 AM)JavaProfit Wrote:  That looks very nice Haze. I can't wait to see it be used in literally every Java application on HF.
I do suggest that the slide-in animation is a bit strange because it goes all the way to the center of the screen.

Thanks bruh. I doubt much people would even use this though ahaha, the avg HF users like skiddy things like booters and crypters. Though this could be in-cooperated with a crypter or booter as a cool feature. Plus yeah I added the slide in animation because I thought it was cool, I liked the way it had this springy element to it's transition.

(Jul 6, 2015 12:40 PM)Weco Wrote:  That looks really great! Nice work you have done there.

Thanks dude :), hope people will find use for it.

(Jul 6, 2015 12:43 PM)MrOrang Wrote:  May I suggest notification lengths.

You could have it use TimeUnit and stuff or maybe a enum like NotificationTime.NORMAL

I've demonstrated that in the thread and in the video. Look at it again.
tray.showAndDismiss(Duration.seconds(2));

You can then specify how long you want it to wait before it dismisses after the entrance. Though you can't delay the Show animation, only the Dismiss animation which when you think about it makes total sense.
Oh derp must have missed that. Anyways is it also possible to put the notifications in other corners such as top left/right and stuff?
(Jul 6, 2015 12:56 PM)MrOrang Wrote:  Oh derp must have missed that. Anyways is it also possible to put the notifications in other corners such as top left/right and stuff?

It's a bit silly for a notification to show up on the top right or top left, by default the notification will appear wherever in alignment with the length of your task Taskbar. Apart from that it will always show on the bottom right.

If you think the notifications could do with new existing features then feel free to fork my code from GitHub and extend them as you wish. I've commented the code so it should be somewhat easy to follow through. If you do MOD it just leave 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."

JWindow. I came across a nice example in another member's code:
https://github.com/JershDervis/MonitorJ-...aster.java
As for C#, I dunno.

Nice work.
(Jul 6, 2015 01:02 PM)WildeThing Wrote:  "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."

JWindow. I came across a nice example in another member's code:
https://github.com/JershDervis/MonitorJ-...aster.java
As for C#, I dunno.

Nice work.

Oh thanks, I will look into the Jni4Net api and see if I can get it working.
(Jul 6, 2015 01:15 PM)+Haze Wrote:  Oh thanks, I will look into the Jni4Net api and see if I can get it working.

I wouldn't bother using Java w/ .NET. Just write it in C#.
(Jul 6, 2015 02:08 PM)WildeThing Wrote:  I wouldn't bother using Java w/ .NET. Just write it in C#.

Remaking those animations in C# would be a nightmare. Especially the slide in animation. I'd rather not looool. C# doesn't have the cool JavaFX animations libs 😏
(Jul 6, 2015 02:15 PM)+Haze Wrote:  Remaking those animations in C# would be a nightmare. Especially the slide in animation. I'd rather not looool. C# doesn't have the cool JavaFX animations libs 😏

Well yeah but if I were you I'd change your sig to say "in your JavaFX apps" since "apps" is pretty vague and I wouldn't use this with Swing or AWT. Other than that, nice one.
(Jul 6, 2015 02:22 PM)WildeThing Wrote:  Well yeah but if I were you I'd change your sig to say "in your JavaFX apps" since "apps" is pretty vague and I wouldn't use this with Swing or AWT. Other than that, nice one.

Thanks mate :D.
I chose my words carefully 😏. I said apps to attract more people to at least look at it, you never know someone could actually gain interest in JavaFX from just looking at this thread (That's how I got into JavaFX).
This looks great , I like it.
Haze finally released it, and glad you made fade in a option too :D The slide in is weird but I defo see others using this alot :P


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by C Plus C Sharp CFeb 22, 2019 06:57 AM 16 995 Feb 22, 2019 06:57 AM
Last Post: C Plus C Sharp C
[Java] by OBAMASELFFeb 8, 2019 03:13 AM 2 204 Feb 8, 2019 03:13 AM
Last Post: OBAMASELF
[Java] by TennoFeb 3, 2019 04:49 AM 4 300 Feb 3, 2019 04:49 AM
Last Post: Tenno