Package totalcross.ui

Class Toast


  • public class Toast
    extends java.lang.Object
    Class used to show a message on screen.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int backColor
      Back color used in the toast.
      static Button btn
      The toast component used to show the text.
      static int extraW
      Extra width of the toast in font's height multiples.
      static int fade
      The stopping fade value, used on transparency.
      static Font font
      The font to be used.
      static int foreColor
      Fore color used in the toast.
      static int height
      Height of the toast.
      static int INFINITE  
      static int INFINITE_NOANIM  
      static int posX
      X position of the toast.
      static int posY
      Y position of the toast.
      static int width
      Width of the toast.
    • Constructor Summary

      Constructors 
      Constructor Description
      Toast()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void show​(java.lang.String message, int delay)
      Shows a toast message using the given parameters on the main window.
      static void show​(java.lang.String message, int delay, Window parentWindow)
      Shows a toast message using the given parameters on the given window.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • backColor

        public static int backColor
        Back color used in the toast.
      • foreColor

        public static int foreColor
        Fore color used in the toast.
      • posX

        public static int posX
        X position of the toast. Defaults to CENTER.
      • posY

        public static int posY
        Y position of the toast. Defaults to BOTTOM - fmH.
      • extraW

        public static int extraW
        Extra width of the toast in font's height multiples. Defaults to 2.
      • width

        public static int width
        Width of the toast. Defaults to PREFERRED.
      • height

        public static int height
        Height of the toast. Defaults to PREFERRED.
      • fade

        public static int fade
        The stopping fade value, used on transparency. Defaults to 200.
      • font

        public static Font font
        The font to be used. Defaults to the default bold font.
      • btn

        public static Button btn
        The toast component used to show the text.
    • Constructor Detail

      • Toast

        public Toast()
    • Method Detail

      • show

        public static void show​(java.lang.String message,
                                int delay)
        Shows a toast message using the given parameters on the main window.
        See Also:
        show(String, int, Window)
      • show

        public static void show​(java.lang.String message,
                                int delay,
                                Window parentWindow)
        Shows a toast message using the given parameters on the given window. Sample:
         String message = "This is a test";
         Toast.show("\n"+message+"\n", 2000);
         
        See the public static fields of this class to show how you can customize the appearance. Calling with a nulled message will make the last toast disappear. The text is splitted if wider than the screen. If delay is INFINITE, it will wait forever until you call show(null,0). If delay is INFINITE_NOANIM, it will wait forever until you call show(null,0) and will not use animation.