Class Toast

java.lang.Object
ca.phon.ui.toast.Toast

public final class Toast extends Object

A message to the user that is displayed in an un-decorated floating window. The window can be displayed for a certain amount of time and/or hidden when clicked.

To create a new toast, use ToastFactory.
E.g.,

 final Toast toast = ToastFactory.makeToast("Hello world!");
 toast.setMessageBackground(Color.red);
 toast.setDisplayTime(2000);
 toast.start(comp);
 

  • Method Details

    • isFinishOnClink

      public boolean isFinishOnClink()
      Is finished on clink?
      Returns:
      boolean
    • setFinishOnClink

      public void setFinishOnClink(boolean v)
    • setMessage

      public void setMessage(String message)
      Set message
      Parameters:
      message -
    • getMessage

      public String getMessage()
    • setMessageBackground

      public void setMessageBackground(Color c)
      Set background color of message
      Parameters:
      c -
    • getMessageBackground

      public Color getMessageBackground()
    • setMessageForeground

      public void setMessageForeground(Color c)
      Foreground
    • getMessageForeground

      public Color getMessageForeground()
    • setDisplayTime

      public void setDisplayTime(long displayTime)
      Set the amount of time the toast is visible.
      Parameters:
      displayTime - display time in ms. A negative displayTime will leave the Toast shown until clicked or otherwise handled by the programmer
    • getDisplayTime

      public long getDisplayTime()
    • addToastListener

      public void addToastListener(ToastListener listener)
      Add a new toast listener
      Parameters:
      listener -
    • removeToastListener

      public void removeToastListener(ToastListener listener)
      Remove a toast listener
      Parameters:
      listener -
    • start

      public void start()
      Start the toast displayed in the center of the screen.
    • start

      public void start(JWindow window)
      Start the toast display in the center of the window.
      Parameters:
      window -
    • start

      public void start(JFrame frame)
      Start the toast display in the center of the frame.
      Parameters:
      frame -
    • start

      public void start(JComponent comp)
      Start the tosast displayed under the given component.
      Parameters:
      component -
    • start

      public void start(JComponent comp, int x, int y)
      Start the toast displayed at the given screen coords for the given component.
      Parameters:
      comp -
      x -
      y -
    • displayNotification

      public void displayNotification()
    • displayNotification

      public void displayNotification(String title)
    • displayNotification

      public void displayNotification(String title, String subtitle)
      Display message as a system notification. On Mac OS X and Windows this will display a new system-level notification.
      Parameters:
      title -
      subtitle -