- java.lang.Object
-
- com.gluonhq.charm.glisten.control.Message
-
- com.gluonhq.charm.glisten.control.Toast
-
public class Toast extends Message
On mobile, toasts are used to display simple messages to the user. They are displayed at the bottom of the screen for a specific amount of time.
Calling
show()
consecutively on different Toasts will put the messages on a FIFO queue, each one will be shown as soon as the previous one is finished showing.Default duration is
Message.LENGTH_SHORT
.Example
The following code creates a Button and a Toast and in the event handler of the button calls
show()
to show the Toast.Button button = new Button("Show toast"); Toast toast = new Toast("This is a toast!"); button.setOnAction(event -> toast.show());
- Since:
- 4.0.0
-
-
Field Summary
-
Fields inherited from class com.gluonhq.charm.glisten.control.Message
LENGTH_LONG, LENGTH_SHORT
-
-
Constructor Summary
Constructors Constructor Description Toast()
Creates an empty Toast message with a duration ofMessage.LENGTH_SHORT
.Toast(String message)
Creates a Toast message with a duration ofMessage.LENGTH_SHORT
.Toast(String message, Duration duration)
Creates a Toast message with a given duration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
If the Message is currently showing, calling this method will hide it immediately and show the next Message in queue.void
show()
Shows the Message immediately, if no other message is showing.-
Methods inherited from class com.gluonhq.charm.glisten.control.Message
durationProperty, getDuration, getId, getMessage, idProperty, messageProperty, setDuration, setId, setMessage
-
-
-
-
Constructor Detail
-
Toast
public Toast()
Creates an empty Toast message with a duration ofMessage.LENGTH_SHORT
.
-
Toast
public Toast(String message)
Creates a Toast message with a duration ofMessage.LENGTH_SHORT
.- Parameters:
message
- the message to display in the Toast control.
-
-
Method Detail
-
show
public void show()
Shows the Message immediately, if no other message is showing. If a message is already showing, it gets added to the waiting queue and will show when its turn arrives.
-
cancel
public void cancel()
If the Message is currently showing, calling this method will hide it immediately and show the next Message in queue. If the Message is waiting in the queue, calling this method removes the Message from the queue and the Message is never shown.
-
-