Class Label

All Implemented Interfaces:
HasLocalTransform, CloneableSmartAsset, Collidable, Savable, JmeCloneable, Cloneable
Direct Known Subclasses:
Button, NLabel

public class Label extends Panel
A standard GUI element for displaying text with an optional shadow.
  • Field Details

  • Constructor Details

  • Method Details

    • initializeDefaultStyles

      public static void initializeDefaultStyles(Attributes attrs)
    • createText2d

      protected Text2d createText2d(ElementId elementId, String style)
      Utility method to encapsulate the font shell game that we play for backwards compatibility. If a Label has overridden the default fontName somewhere in its style hierarchy then that will always be used here. Otherwise, the bitmap "font" styling is checked. If that is different than the default 'font' style then it is used. If the local 'font' style is the same as the default 'font' style then the font name is used, regardless of if it was overridden or not. In this way, any existing style hierarchies should continue to work with actual BitmapFonts will also seemlessly supporting 'fontName' styles. 'fontName' is preferred going forward because it better supports overriding Text2d implementations.
    • setText

      @StyleAttribute(value="text", lookupDefault=false) public void setText(String s)
    • getText

      public String getText()
    • setTextVAlignment

      @StyleAttribute(value="textVAlignment", lookupDefault=false) public void setTextVAlignment(VAlignment a)
    • getTextVAlignment

      public VAlignment getTextVAlignment()
    • setTextHAlignment

      @StyleAttribute(value="textHAlignment", lookupDefault=false) public void setTextHAlignment(HAlignment a)
    • getTextHAlignment

      public HAlignment getTextHAlignment()
    • setMaxWidth

      @StyleAttribute(value="maxWidth", lookupDefault=false) public void setMaxWidth(float f)
      Sets the maximum width of the label. If the text is longer than this width then it will be wrapped and the label will grow vertically (in a way that the layout's can use for proper positioning).
    • getMaxWidth

      public float getMaxWidth()
    • setFont

      public void setFont(BitmapFont font)
    • getFont

      public BitmapFont getFont()
    • setFontName

      @StyleAttribute("fontName") public void setFontName(String fontName)
    • getFontName

      public String getFontName()
    • setColor

      @StyleAttribute("color") public void setColor(ColorRGBA color)
    • getColor

      public ColorRGBA getColor()
    • setFontSize

      @StyleAttribute("fontSize") public void setFontSize(float f)
    • getFontSize

      public float getFontSize()
    • setShadowOffset

      @StyleAttribute("shadowOffset") public void setShadowOffset(Vector3f offset)
    • getShadowOffset

      public Vector3f getShadowOffset()
    • setShadowColor

      @StyleAttribute(value="shadowColor", lookupDefault=false) public void setShadowColor(ColorRGBA color)
    • getShadowColor

      public ColorRGBA getShadowColor()
    • setIcon

      @StyleAttribute(value="icon", lookupDefault=false) public void setIcon(GuiComponent icon)
    • getIcon

      public GuiComponent getIcon()
    • toString

      public String toString()
      Description copied from class: Spatial
      Returns the Spatial's name followed by the class of the spatial
      Example: "MyNode (com.jme3.scene.Spatial)"
      Overrides:
      toString in class Panel
      Returns:
      Spatial's name followed by the class of the Spatial