Class NotificationBuilder
java.lang.Object
ch.swingfx.twinkle.NotificationBuilder
This class lets you build a notification window.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intDuration of the fade in animation in millisecondsprivate static final intdelay before we start the fade in animation because of flickering on some systems/jres.private static final intDuration of the fade out animation in millisecondsprivate static final intThe default display time for a notification in millisecondsprivate intTime in millis we want to display the notificationprivate booleanFlag that tells us if we should fade in the notificationprivate booleanFlag that tells us if we should fade out the notificationprivate IconThe Icon we want to displayprivate final UUIDid of thisNotificationBuilder.private INotificationManagerThe manager that shows the notificationsprivate StringThe message we want to displayprivate INotificationEventListenerListener that receives notification eventsprivate IPositionPosition of the notificationprivate INotificationStylestyling for our windowprivate StringThe title we want to displayprivate booleanFlag that tells us if the window is closed or notprivate static final GraphicsDeviceprivate static final GraphicsConfigurationprivate static InsetsInsets of menu/task barsprivate static final DimensionThe size of the main screen including all the menu/task barsprivate static final Toolkitprivate static final ch.swingfx.window.translucentandshaped.ITranslucentAndShapedWindowApiapi for Translucent and Shaped Windowsprivate static final intversion of the library -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcloseWindow(JWindow window) Closes the windowgetStyle()Get theINotificationStyleof this notificationshows the notificationprivate voidwithDisplayTime(int timeInMillis) set the time the notification should be displayedwithFadeInAnimation(boolean animate) set true if you want to fade in the notification.
Note fade in is not supported on all platform.withFadeOutAnimation(boolean animate) set true if you want to fade out the notification.
Note fade out is not supported on all platform.set the icon of the notificationset the icon of the notificationwithListener(INotificationEventListener listener) Sets aINotificationEventListenerfor receiving events from the notificationwithMessage(String message) set the message of the notificationSet theINotificationManagerthat handles how the notification are displayedwithPosition(IPosition position) Set the position of the notificationwithStyle(INotificationStyle style) set the style of the notificationset the title of the notification
-
Field Details
-
version
private static final int versionversion of the library- See Also:
-
ANIMATION_FADE_IN_DURATION
private static final int ANIMATION_FADE_IN_DURATIONDuration of the fade in animation in milliseconds- See Also:
-
ANIMATION_FADE_OUT_DURATION
private static final int ANIMATION_FADE_OUT_DURATIONDuration of the fade out animation in milliseconds- See Also:
-
ANIMATION_FADE_IN_START_DELAY
private static final int ANIMATION_FADE_IN_START_DELAYdelay before we start the fade in animation because of flickering on some systems/jres.- See Also:
-
DEFAULT_DISPLAY_TIME_IN_MILLIS
private static final int DEFAULT_DISPLAY_TIME_IN_MILLISThe default display time for a notification in milliseconds- See Also:
-
fId
id of thisNotificationBuilder. Sent inNotificationEvent -
fIcon
The Icon we want to display -
fTitle
The title we want to display -
fMessage
The message we want to display -
fDisplayTime
private int fDisplayTimeTime in millis we want to display the notification -
fNotificationListener
Listener that receives notification events -
fStyle
styling for our window -
fPosition
Position of the notification -
fFadeIn
private boolean fFadeInFlag that tells us if we should fade in the notification -
fFadeOut
private boolean fFadeOutFlag that tells us if we should fade out the notification -
fWindowClosed
private boolean fWindowClosedFlag that tells us if the window is closed or not -
fManager
The manager that shows the notifications -
sWindowApi
private static final ch.swingfx.window.translucentandshaped.ITranslucentAndShapedWindowApi sWindowApiapi for Translucent and Shaped Windows -
sMainScreen
-
sMainScreenGraphicsConfiguration
-
sMainScreenSize
The size of the main screen including all the menu/task bars -
sMainScreenInsets
Insets of menu/task bars -
sToolkit
-
-
Constructor Details
-
NotificationBuilder
public NotificationBuilder()
-
-
Method Details
-
withStyle
set the style of the notification- Parameters:
style- the style of the notification- Returns:
- this
NotificationBuilder
-
withIcon
set the icon of the notification- Parameters:
iconPath- path to the icon- Returns:
- this
NotificationBuilder
-
withIcon
set the icon of the notification- Parameters:
icon- the icon- Returns:
- this
NotificationBuilder
-
withTitle
set the title of the notification- Parameters:
title- the title- Returns:
- this
NotificationBuilder
-
withMessage
set the message of the notification- Parameters:
message- the message- Returns:
- this
NotificationBuilder
-
withDisplayTime
set the time the notification should be displayed- Parameters:
timeInMillis- time in milliseconds. minimum 1000- Returns:
- this
NotificationBuilder
-
withPosition
Set the position of the notification- Parameters:
position- position of the notification- Returns:
- this
NotificationBuilder
-
withFadeInAnimation
set true if you want to fade in the notification.
Note fade in is not supported on all platform. If it doesn't work on a platform it will use no animation.- Parameters:
animate- true if you want to fade in the notification- Returns:
- this
NotificationBuilder
-
withFadeOutAnimation
set true if you want to fade out the notification.
Note fade out is not supported on all platform. If it doesn't work on a platform it will use no animation.- Parameters:
animate- true if you want to fade in the notification- Returns:
- this
NotificationBuilder
-
withListener
Sets aINotificationEventListenerfor receiving events from the notification- Parameters:
listener- listener to add- Returns:
- this
NotificationBuilder
-
withNotificationManager
Set theINotificationManagerthat handles how the notification are displayed- Parameters:
manager-INotificationManagerto use- Returns:
- this
NotificationBuilder
-
getStyle
Get theINotificationStyleof this notification- Returns:
- the
INotificationStyleof this notification
-
showNotification
shows the notification- Returns:
- Unique identifier for this notification. Call NotificationEvent.getId() to retrieve this id
-
showNotificationEDT
private void showNotificationEDT() -
closeWindow
-