Class BasicStyledLabelUI

All Implemented Interfaces:
PropertyChangeListener, EventListener, SwingConstants

public class BasicStyledLabelUI extends BasicLabelUI implements SwingConstants
  • Field Details

  • Constructor Details

    • BasicStyledLabelUI

      public BasicStyledLabelUI()
  • Method Details

    • createUI

      public static ComponentUI createUI(JComponent c)
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Specified by:
      propertyChange in interface PropertyChangeListener
      Overrides:
      propertyChange in class BasicLabelUI
    • paintEnabledText

      protected void paintEnabledText(JLabel l, Graphics g, String s, int textX, int textY)
      Overrides:
      paintEnabledText in class BasicLabelUI
    • paintDisabledText

      protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY)
      Overrides:
      paintDisabledText in class BasicLabelUI
    • buildStyledText

      protected void buildStyledText(StyledLabel label)
    • getPreferredSize

      public Dimension getPreferredSize(JComponent c)
      Overrides:
      getPreferredSize in class BasicLabelUI
    • layoutCL

      protected String layoutCL(JLabel label, FontMetrics fontMetrics, String text, Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR)
      Overrides:
      layoutCL in class BasicLabelUI
    • getPreferredSize

      protected Dimension getPreferredSize(StyledLabel label)
      Gets the preferred size of the text portion of the StyledLabel including the icon.
      Parameters:
      label - the StyledLabel
      Returns:
      the preferred size.
    • getFont

      protected Font getFont(StyledLabel label)
      Gets the font from the label.
      Parameters:
      label - the label.
      Returns:
      the font. If label's getFont is null, we will use Label.font instead.
    • paintStyledText

      protected void paintStyledText(StyledLabel label, Graphics g, int textX, int textY)
    • layoutCompoundLabel

      public static String layoutCompoundLabel(JComponent c, FontMetrics fm, String text, Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int textIconGap)
      Compute and return the location of the icons origin, the location of origin of the text baseline, and a possibly clipped version of the compound labels string. Locations are computed relative to the viewR rectangle. The JComponents orientation (LEADING/TRAILING) will also be taken into account and translated into LEFT/RIGHT values accordingly.
      Parameters:
      c - the component
      fm - the font metrics
      text - the text
      icon - the icon
      verticalAlignment - vertical alignment mode
      horizontalAlignment - horizontal alignment mode
      verticalTextPosition - vertical text position
      horizontalTextPosition - horizontal text position
      viewR - view rectangle
      iconR - icon rectangle
      textR - text rectangle
      textIconGap - the gap between text and icon
      Returns:
      the layout string
    • layoutCompoundLabel

      public static String layoutCompoundLabel(FontMetrics fm, String text, Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int textIconGap)
      Compute and return the location of the icons origin, the location of origin of the text baseline, and a possibly clipped version of the compound labels string. Locations are computed relative to the viewR rectangle. This layoutCompoundLabel() does not know how to handle LEADING/TRAILING values in horizontalTextPosition (they will default to RIGHT) and in horizontalAlignment (they will default to CENTER). Use the other version of layoutCompoundLabel() instead.
      Parameters:
      fm - the font metrics
      text - the text
      icon - the icon
      verticalAlignment - vertical alignment mode
      horizontalAlignment - horizontal alignment mode
      verticalTextPosition - vertical text position
      horizontalTextPosition - horizontal text position
      viewR - view rectangle
      iconR - icon rectangle
      textR - text rectangle
      textIconGap - the gap between text and icon
      Returns:
      the layout string