GithubHelp home page GithubHelp logo

pruxis / traynotification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from plushaze/traynotification

0.0 2.0 0.0 123 KB

A tray notification class in JavaFX that allows you to call beautiful looking notifications on desktop computers.

License: MIT License

Java 100.00%

traynotification's Introduction

Tray Notification

Tray Notification is a library for JavaFX that adds easy-to-use tray notifications for desktop computers.

There are 5 included notifications and 3 included animations, but you're able to also add your own.


Creating a new tray notification

To use, create an instance of TrayNotification and define its title, message and notification.

        String title = "Congratulations sir";
        String message = "You've successfully created your first Tray Notification";
        Notification notification = Notifications.SUCCESS;
        
        TrayNotification tray = new TrayNotification();
        tray.setTitle(title);
        tray.setMessage(message);
        tray.setNotification(notification);
        tray.showAndWait();

Alternatively you can initialize the tray notification with its non-default constructors.

        TrayNotification tray = new TrayNotification(title, message, notification);
        tray.showAndWait();



The default animation is a sliding animation.

When shownAndWait() is called, the tray notification will show and wait until it is either dismissed with the close button or programmatically through your code.






Using different animations and notifications

You can also individually customize notifications and animations.
Using a notice notification with a fading animation, for example:

        String title = "Download quota reached";
        String message = "Your download quota has been reached. Panic.";
        Notification notification = Notifications.NOTICE;
        
        tray.setTitle(title);
        tray.setMessage(message);
        tray.setNotification(notification);
        tray.setAnimation(Animations.FADE);
        tray.showAndWait();





Creating a custom tray notification


You're also able to set a custom image or rectangle fill. You can use showAndDismiss, which will show both the show and dismiss animation. You're also able to control the delay before dismissal following the show animation. This is useful for when you want a notification to appear for a certain amount of time before closing.

        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.setAnimation(Animations.POPUP);
        tray.setImage(whatsAppImg);
        tray.showAndDismiss(Duration.seconds(2));



Setting a new tray overload methods

A shorthand to changing the design of a tray animation is to use the setTray's overloaded methods.

        tray.setTray("Title", "Message", Notifications.ERROR);
        tray.showAndWait();
        
        //OR
        tray.setTray("Title", "Message", whatsAppImg, Paint.valueOf("#2A9A84") , Animations.POPUP);
        tray.showAndDismiss(Duration.seconds(10));

YouTube video demonstration

The video below showcases the TrayTester.jar app which you can get here.

Click the image below to watch the YouTube video.



traynotification's People

Contributors

plushaze avatar

Watchers

James Cloos avatar Laurens Lavaert avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.