Class LabelWidget

java.lang.Object
org.netbeans.api.visual.widget.Widget
org.netbeans.api.visual.widget.LabelWidget
All Implemented Interfaces:
Accessible, org.openide.util.Lookup.Provider
Direct Known Subclasses:
ListItemWidget

public class LabelWidget extends Widget
A widget representing a text. The widget is not opaque and is checking clipping for by default.

It allows to set 4 types of horizontal and vertical alignments (by default LEFT as horizontal and BASELINE as vertical).

Swing Font-hinting feature may cause the labels are not rendered completely. Using setUseGlyphVector you may force the label to be converted to a glyph vector which scales correctly for any zoom factor.

  • Constructor Details

    • LabelWidget

      public LabelWidget(Scene scene)
      Creates a label widget.
      Parameters:
      scene - the scene
    • LabelWidget

      public LabelWidget(Scene scene, String label)
      Creates a label widget with a label.
      Parameters:
      scene - the scene
      label - the label
  • Method Details

    • getLabel

      public String getLabel()
      Returns a label.
      Returns:
      the label
    • setLabel

      public void setLabel(String label)
      Sets a label.
      Parameters:
      label - the label
    • getAlignment

      public LabelWidget.Alignment getAlignment()
      Returns a text horizontal alignment.
      Returns:
      the text horizontal alignment
    • setAlignment

      public void setAlignment(LabelWidget.Alignment alignment)
      Sets a text horizontal alignment.
      Parameters:
      alignment - the text horizontal alignment
    • getVerticalAlignment

      public LabelWidget.VerticalAlignment getVerticalAlignment()
      Gets a text vertical alignment.
      Returns:
      the text vertical alignment
    • setVerticalAlignment

      public void setVerticalAlignment(LabelWidget.VerticalAlignment verticalAlignment)
      Sets a text vertical alignment.
      Parameters:
      verticalAlignment - the text vertical alignment
    • getOrientation

      public LabelWidget.Orientation getOrientation()
      Gets a text orientation.
      Returns:
      the text orientation
      Since:
      2.1
    • setOrientation

      public void setOrientation(LabelWidget.Orientation orientation)
      Sets a text orientation.
      Parameters:
      orientation - the text orientation
      Since:
      2.1
    • isPaintAsDisabled

      public boolean isPaintAsDisabled()
      Returns whether the label is painted as disabled.
      Returns:
      true, if the label is painted as disabled
    • setPaintAsDisabled

      public void setPaintAsDisabled(boolean paintAsDisabled)
      Sets whether the label is painted as disabled.
      Parameters:
      paintAsDisabled - if true, then the label is painted as disabled
    • isUseGlyphVector

      public boolean isUseGlyphVector()
      Returns whether the label widget is using glyph vector for rendering text.
      Returns:
      true, if the label widget is using glyph vector
      Since:
      2.7
    • setUseGlyphVector

      public void setUseGlyphVector(boolean useGlyphVector)
      Sets whether the label widget is using glyph vector for rendering text.

      Note that using glyph vector could slow-down the rendering performance. Note that if you are not using glyph vector then the text may be clipped when a scene has zoom factor different from 1.0.

      Parameters:
      useGlyphVector - if true, then a glyph vector is used for rendering text
      Since:
      2.7
    • calculateClientArea

      protected Rectangle calculateClientArea()
      Calculates a client area for the label.
      Overrides:
      calculateClientArea in class Widget
      Returns:
      the client area
    • paintWidget

      protected void paintWidget()
      Paints the label widget.
      Overrides:
      paintWidget in class Widget