Class Label


public final class Label extends Entry
Read-only text on its own row: an explanation, a heading, or a value to show. Long text wraps onto several lines.
Label.builder("info")
        .text(() -> Text.translatable("mymod.info", "%s profiles saved", profiles.size()))
        .build();

Required: text. For the outcome of an action ("Saved", "Failed: …"), use a StatusLine instead, which has a severity and starts empty.

  • Method Details

    • builder

      public static Label.Builder builder(String id)
      Starts building a label.
      Parameters:
      id - the label's id, unique within its screen
      Returns:
      a new builder
      Throws:
      IllegalArgumentException - if id is invalid
    • text

      public Text text()
      The text shown, from the mod's supplier.
      Returns:
      the text the label shows
    • accept

      public <R> R accept(EntryVisitor<R> visitor)
      Description copied from class: Entry
      Calls the EntryVisitor method for this entry's type (visitButton for a Button, …) and returns its result. A Section visits as its header, a NumberField as its TextInput.
      Specified by:
      accept in class Entry
      Type Parameters:
      R - the visitor's result type
      Parameters:
      visitor - the visitor, usually a backend's widget factory
      Returns:
      what the visitor returned