Class Banner

All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>

public class Banner extends Container

A strip of important information inside the page, with optional actions and a close button: the Material banner.

Form form = new Form("Inbox", BoxLayout.y());
Banner offline = new Banner("You are offline. Changes are saved on this device.");
offline.addAction("Retry", e -> Log.p("Retry"));
offline.setDismissible(true);
form.add(offline);
form.show();

Unlike a ToastBar it stays until it is dismissed and takes its own space, so it suits a state that lasts, such as being offline. dismiss() removes it with an animation and tells the dismiss listeners. The UIIDs are Banner, BannerText, BannerIcon, BannerAction and BannerClose.

  • Constructor Details

    • Banner

      public Banner(String message)

      A banner showing a message.

      Parameters
      • message: the text of the banner
  • Method Details

    • getText

      public String getText()
      The message.
    • setText

      public void setText(String message)

      Replaces the message.

      Parameters
      • message: the text
    • setIcon

      public void setIcon(Image image)

      Shows an icon before the message; null removes it.

      Parameters
      • image: the icon
    • addAction

      public Button addAction(String label, ActionListener l)

      Adds a text button under the message. It does not dismiss the banner; call dismiss() from the listener when it should.

      Parameters
      • label: the text of the button
      • l: called when it is tapped
      Returns

      the button

    • setDismissible

      public void setDismissible(boolean dismissible)

      Shows or hides a close button that dismisses the banner.

      Parameters
      • dismissible: true for a close button
    • isDismissible

      public boolean isDismissible()
      True when the banner has a close button.
    • addDismissListener

      public void addDismissListener(ActionListener l)

      Adds a listener told when the banner is dismissed.

      Parameters
      • l: the listener
    • removeDismissListener

      public void removeDismissListener(ActionListener l)

      Removes a dismiss listener.

      Parameters
      • l: the listener
    • dismiss

      public void dismiss()
      Removes the banner from its parent and tells the dismiss listeners.