Class JMultilineLabel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class JMultilineLabel extends JEditorPane
Creates a normal label that will wrap its contents if there less width than required to print it in one line. Additionally the maximum width of the text can be set using setMaxWidth. Note that this won't work if JMultilineLabel is put into a JScrollBox or similar as the bounds will never change. Instead scrollbars will be displayed.
Since:
6340
See Also:
  • Field Details

  • Constructor Details

    • JMultilineLabel

      public JMultilineLabel(String text)
      Constructs a normal label but adds HTML tags if not already done so. Supports both newline characters (\n) as well as the HTML <br> to insert new lines. Use setMaxWidth to limit the width of the label.
      Parameters:
      text - The text to display
    • JMultilineLabel

      public JMultilineLabel(String text, boolean allBold)
      Constructs a normal label but adds HTML tags if not already done so. Supports both newline characters (\n) as well as the HTML <br> to insert new lines. Use setMaxWidth to limit the width of the label.
      Parameters:
      text - The text to display
      allBold - If true, makes all text to be displayed in bold
    • JMultilineLabel

      public JMultilineLabel(String text, boolean allBold, boolean focusable)
      Constructs a normal label but adds HTML tags if not already done so. Supports both newline characters (\n) as well as the HTML <br> to insert new lines. Use setMaxWidth to limit the width of the label.
      Parameters:
      text - The text to display
      allBold - If true, makes all text to be displayed in bold
      focusable - indicates whether this label is focusable
      Since:
      13157
  • Method Details

    • setMaxWidth

      public void setMaxWidth(int width)
      Set the maximum width. Use this method instead of setMaximumSize because this saves a little bit of overhead and is actually taken into account.
      Parameters:
      width - the maximum width
    • getPreferredSize

      Tries to determine a suitable height for the given contents and return that dimension.
      Overrides:
      getPreferredSize in class JEditorPane