Package org.openstreetmap.josm.gui
Class Notification
java.lang.Object
org.openstreetmap.josm.gui.Notification
A Notification Message similar to a popup window, but without disrupting the
user's workflow.
Non-modal info panel that vanishes after a certain time.
This class only holds the data for a notification,
NotificationManager
is responsible for building the message panel and displaying it on screen.
example:
Notification note = new Notification("Hi there!");
note.setIcon(JOptionPane.INFORMATION_MESSAGE); // optional
note.setDuration(Notification.TIME_SHORT); // optional
note.show();
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Componentstatic final intDefault width of a notificationprivate intprivate Stringprivate Iconstatic final intShort message of one or two lines (5 s).static final intSomewhat longer message (10 s).static final intVery short and very easy to grasp message (3 s).static final intLong text. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newNotificationwithout content.Notification(String msg) Constructs a newNotificationwith the given textual content. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the content component to use.private ObjectintGets the time the notification should be displayedGets the help topic for this notificationgetIcon()Gets the icon that should be displayed next to the notificationinthashCode()voidreplaceExisting(Notification oldNotification) Display the notification by replacing the given queued/displaying notificationsetContent(Component content) Set the content of the message.setContent(String msg) Set the notification text.setDuration(int duration) Set the time after which the message is hidden.setHelpTopic(String helpTopic) Display a help button at the bottom of the notification window.setIcon(int messageType) Set an icon to display on the left part of the message window by choosing from the default JOptionPane icons.Set an icon to display on the left part of the message window.voidshow()Display the notification.toString()
-
Field Details
-
DEFAULT_CONTENT_WIDTH
Default width of a notification- See Also:
-
TIME_SHORT
Very short and very easy to grasp message (3 s). E.g. "Please select at least one node". -
TIME_DEFAULT
Short message of one or two lines (5 s). -
TIME_LONG
Somewhat longer message (10 s). -
TIME_VERY_LONG
Long text. (Make sure is still sensible to show as a notification) -
-
duration
-
icon
-
helpTopic
-
-
Constructor Details
-
Notification
public Notification()Constructs a newNotificationwithout content. -
Notification
Constructs a newNotificationwith the given textual content.- Parameters:
msg- The text to display
-
-
Method Details
-
setContent
Set the content of the message.- Parameters:
content- any Component to be shown- Returns:
- the current Object, for convenience
- See Also:
-
setContent
Set the notification text. (Convenience method)- Parameters:
msg- the message String. Will be wrapped in <html>, so you can use <br> and other markup directly.- Returns:
- the current Object, for convenience
- See Also:
-
setDuration
Set the time after which the message is hidden.- Parameters:
duration- the time (in milliseconds) Preset valuesTIME_SHORT,TIME_DEFAULT,TIME_LONGandTIME_VERY_LONGcan be used.- Returns:
- the current Object, for convenience
-
setIcon
Set an icon to display on the left part of the message window.Icons larger than
ImageProvider.ImageSizes.NOTIFICATIONare scaled down.- Parameters:
icon- the icon (null means no icon is displayed)- Returns:
- the current Object, for convenience
-
setIcon
Set an icon to display on the left part of the message window by choosing from the default JOptionPane icons.- Parameters:
messageType- one of the following: JOptionPane.ERROR_MESSAGE, JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE, JOptionPane.QUESTION_MESSAGE, JOptionPane.PLAIN_MESSAGE- Returns:
- the current Object, for convenience
-
setHelpTopic
Display a help button at the bottom of the notification window.- Parameters:
helpTopic- the help topic- Returns:
- the current Object, for convenience
-
getContent
Gets the content component to use.- Returns:
- The content
-
getDuration
Gets the time the notification should be displayed- Returns:
- The time to display the notification
-
getIcon
Gets the icon that should be displayed next to the notification- Returns:
- The icon to display
-
getHelpTopic
Gets the help topic for this notification- Returns:
- The help topic
-
show
Display the notification. -
replaceExisting
Display the notification by replacing the given queued/displaying notification- Parameters:
oldNotification- the notification to replace- Since:
- 17628
-
getContentTextOrComponent
-
equals
-
hashCode
-
toString
-