Class LabelSkin

    • Constructor Detail

      • LabelSkin

        public LabelSkin()
        Default constructor.
    • Method Detail

      • install

        public void install​(Component component)
        Description copied from class: ComponentSkin
        Must be implemented in every subclass in order to do component-specific operations at instantiation time, but every subclass must call this superclass method to setup the necessary listeners, etc.
        Specified by:
        install in interface Skin
        Overrides:
        install in class ComponentSkin
        Parameters:
        component - The component to which the skin is being attached.
      • getPreferredWidth

        public int getPreferredWidth​(int height)
        Description copied from interface: ConstrainedVisual
        Returns the visual's preferred width given the provided height constraint.
        Specified by:
        getPreferredWidth in interface ConstrainedVisual
        Parameters:
        height - The height by which to constrain the preferred width, or -1 for no constraint.
        Returns:
        The preferred width given the height constraint.
      • getPreferredHeight

        public int getPreferredHeight​(int width)
        Description copied from interface: ConstrainedVisual
        Returns the visual's preferred height given the provided width constraint.
        Specified by:
        getPreferredHeight in interface ConstrainedVisual
        Parameters:
        width - The width by which to constrain the preferred height, or -1 for no constraint.
        Returns:
        The preferred height given the width constraint.
      • getBaseline

        public int getBaseline​(int width,
                               int height)
        Description copied from class: ComponentSkin
        Should be implemented in every subclass.

        The default implementation here simply returns -1 (no baseline).

        Specified by:
        getBaseline in interface ConstrainedVisual
        Overrides:
        getBaseline in class ComponentSkin
        Parameters:
        width - Constrained width to compute the baseline for.
        height - Constrained height to compute the baseline for.
        Returns:
        The baseline relative to the origin of this visual, or -1 if this visual does not have a baseline.
      • layout

        public void layout()
        Description copied from interface: Skin
        If the component on which the skin is installed is a container, lays out the container's children.
        Specified by:
        layout in interface Skin
      • paint

        public void paint​(java.awt.Graphics2D graphics)
        Description copied from interface: Visual
        Paints the visual.
        Specified by:
        paint in interface Visual
        Parameters:
        graphics - The graphics context in which to paint the visual.
      • isOpaque

        public boolean isOpaque()
        Description copied from class: ComponentSkin
        By default, skins are assumed to be opaque.
        Specified by:
        isOpaque in interface Skin
        Overrides:
        isOpaque in class ComponentSkin
        Returns:
        true if this skin is opaque; false if any part of it is transparent or translucent.
      • getFont

        public java.awt.Font getFont()
        Returns:
        The font used in rendering the Label's text.
      • setFont

        public void setFont​(java.lang.Object fontValue)
        Sets the font used in rendering the Label's text.
        Parameters:
        fontValue - The new font to use to render the text of a type supported by ComponentSkin.fontFromObject(java.lang.Object).
      • getColor

        public java.awt.Color getColor()
        Returns:
        The foreground color of the text of the label.
      • setColor

        public void setColor​(java.lang.Object colorValue)
        Sets the foreground color of the text of the label.
        Parameters:
        colorValue - The new foreground color for the label text, which can be interpreted by ComponentSkin.colorFromObject(java.lang.Object).
      • getDisabledColor

        public java.awt.Color getDisabledColor()
        Returns:
        The foreground color of the text of the label when disabled.
      • setDisabledColor

        public void setDisabledColor​(java.lang.Object colorValue)
        Sets the foreground color of the text of the label when disabled.
        Parameters:
        colorValue - The new disabled text color, which can be interpreted by ComponentSkin.colorFromObject(java.lang.Object).
      • getBackgroundColor

        public java.awt.Color getBackgroundColor()
        Returns:
        The background color of the label.
      • setBackgroundColor

        public final void setBackgroundColor​(java.lang.Object colorValue)
        Sets the background color of the label.
        Parameters:
        colorValue - The new background color for the label (can be null to let the parent background show through), or a value that can be interpreted by ComponentSkin.colorFromObject(java.lang.Object).
      • getTextDecoration

        public TextDecoration getTextDecoration()
        Returns:
        The current text decoration (strikethrough, underline, etc) for the label (can be null).
      • setTextDecoration

        public void setTextDecoration​(TextDecoration textDecorationValue)
        Sets the text decoration (eg, strikethrough, underline, etc) for this label.
        Parameters:
        textDecorationValue - The new setting (can be null to cancel any decoration for the label).
      • getHorizontalAlignment

        public HorizontalAlignment getHorizontalAlignment()
        Returns:
        The horizontal alignment for the label to use when drawing the text inside the label's total width.
      • setHorizontalAlignment

        public void setHorizontalAlignment​(HorizontalAlignment horizontalAlignmentValue)
        Set the horizontal alignment for the text inside the label's total width.
        Parameters:
        horizontalAlignmentValue - The new setting.
        Throws:
        java.lang.IllegalArgumentException - if the value is null.
      • getVerticalAlignment

        public VerticalAlignment getVerticalAlignment()
        Returns:
        The vertical alignment used to draw the text inside the label's total height.
      • setVerticalAlignment

        public void setVerticalAlignment​(VerticalAlignment verticalAlignmentValue)
        Set the new vertical alignment value for the text inside the label's height.
        Parameters:
        verticalAlignmentValue - The new setting.
        Throws:
        java.lang.IllegalArgumentException - if the new value is null.
      • getPadding

        public Insets getPadding()
        Returns:
        The amount of space to leave between the edge of the Label and its text.
      • setPadding

        public void setPadding​(java.lang.Object paddingValues)
        Sets the amount of space to leave between the edge of the Label and its text.
        Parameters:
        paddingValues - The new value of the padding for each edge, of any type supported by Insets.fromObject(java.lang.Object).
      • getWrapText

        public boolean getWrapText()
        Returns:
        true if the text of the label will be wrapped to fit the Label's width.
      • setWrapText

        public void setWrapText​(boolean wrapTextValue)
        Sets whether the text of the label will be wrapped to fit the Label's width. Note that for wrapping to occur, the Label must specify a preferred width or be placed in a container that constrains its width.

        Also note that newline characters (if wrapping is set true) will cause a hard line break.

        Parameters:
        wrapTextValue - Whether or not to wrap the Label's text within its width.
      • textChanged

        public void textChanged​(Label label,
                                java.lang.String previousText)
        Description copied from interface: LabelListener
        Called when a label's text has changed.
        Specified by:
        textChanged in interface LabelListener
        Parameters:
        label - The label that has changed.
        previousText - The previous text associated with the label.
      • maximumLengthChanged

        public void maximumLengthChanged​(Label label,
                                         int previousMaximumLength)
        Description copied from interface: LabelListener
        Called when a label text maximum length has changed.
        Specified by:
        maximumLengthChanged in interface LabelListener
        Parameters:
        label - The label that has changed.
        previousMaximumLength - The previous maximum text length for the label.