Package ch.swingfx.twinkle
Class NotificationBuilder
java.lang.Object
ch.swingfx.twinkle.NotificationBuilder
This class lets you build a notification window.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
Duration of the fade in animation in millisecondsprivate static final int
delay before we start the fade in animation because of flickering on some systems/jres.private static final int
Duration of the fade out animation in millisecondsprivate static final int
The default display time for a notification in millisecondsprivate int
Time in millis we want to display the notificationprivate boolean
Flag that tells us if we should fade in the notificationprivate boolean
Flag that tells us if we should fade out the notificationprivate Icon
The Icon we want to displayprivate final UUID
id of thisNotificationBuilder
.private INotificationManager
The manager that shows the notificationsprivate String
The message we want to displayprivate INotificationEventListener
Listener that receives notification eventsprivate IPosition
Position of the notificationprivate INotificationStyle
styling for our windowprivate String
The title we want to displayprivate boolean
Flag that tells us if the window is closed or notprivate static final GraphicsDevice
private static final GraphicsConfiguration
private static Insets
Insets of menu/task barsprivate static final Dimension
The size of the main screen including all the menu/task barsprivate static final Toolkit
private static final ch.swingfx.window.translucentandshaped.ITranslucentAndShapedWindowApi
api for Translucent and Shaped Windowsprivate static final int
version of the library -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
closeWindow
(JWindow window) Closes the windowgetStyle()
Get theINotificationStyle
of this notificationshows the notificationprivate void
withDisplayTime
(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 aINotificationEventListener
for receiving events from the notificationwithMessage
(String message) set the message of the notificationSet theINotificationManager
that 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 aINotificationEventListener
for receiving events from the notification- Parameters:
listener
- listener to add- Returns:
- this
NotificationBuilder
-
withNotificationManager
Set theINotificationManager
that handles how the notification are displayed- Parameters:
manager
-INotificationManager
to use- Returns:
- this
NotificationBuilder
-
getStyle
Get theINotificationStyle
of this notification- Returns:
- the
INotificationStyle
of this notification
-
showNotification
shows the notification- Returns:
- Unique identifier for this notification. Call NotificationEvent.getId() to retrieve this id
-
showNotificationEDT
private void showNotificationEDT() -
closeWindow
Closes the window- Parameters:
window
- the window to close
-