Class MultiLabel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class MultiLabel extends JPanel
Component similar to a JLabel, but it can display text in multiple lines. Line breaks will be added automatically to keep the text within the component's bounds. Any line break characters already present will be retained.
See Also:
  • Constructor Details

    • MultiLabel

      public MultiLabel(String label, int width, int border, Font font)
      Creates a new MultiLabel with the specified text label.
      Parameters:
      label - The intial text label.
      width - The preferred width of the component.
      border - The distance from the edge where no text is painted.
      font - The font used for this component.
    • MultiLabel

      public MultiLabel(String label, int width, int border)
      Creates a new MultiLabel with the specified text label.
      Parameters:
      label - The intial text label.
      width - The preferred width of the component.
      border - The distance from the edge where no text is painted.
    • MultiLabel

      public MultiLabel(String label, int width)
      Creates a new MultiLabel with the specified text label. The height of the component will be auto-detected, and a default border thickness of 5 pixels will be used.
      Parameters:
      label - The intial text label.
      width - The preferred width of the component.
  • Method Details

    • paintComponent

      protected void paintComponent(Graphics g)
      Repaints this label. The text will be layed out according to the width of the component.
      Overrides:
      paintComponent in class JComponent
    • recalculateHeight

      public void recalculateHeight(int width)
    • setLabel

      public void setLabel(String label, boolean forceRescale)
    • setLabel

      public void setLabel(String label)
    • getLabel

      public String getLabel()