Class TextPane

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class TextPane extends JComponent
Displays a string of text.
See Also:
  • Constructor Details

    • TextPane

      public TextPane()
      Constructs a text pane.
    • TextPane

      public TextPane(String text)
      Constructs a text pane.
      Parameters:
      text - The text to display, or null for no text.
  • Method Details

    • getText

      public String getText()
      Returns the text displayed by the component.
      Returns:
      The text displayed by the component.
    • setText

      public void setText(String text)
      Sets the text displayed by the component.
      Parameters:
      text - The text to display, or null for no text.
    • getWrapText

      public boolean getWrapText()
      Indicates that line wrapping is enabled. The default value is false.
      Returns:
      true if the text will wrap when needed; false, otherwise.
    • setWrapText

      public void setWrapText(boolean wrapText)
      Toggles line wrapping.
      Parameters:
      wrapText - true to wrap text when needed; false, otherwise.
    • getHorizontalAlignment

      public HorizontalAlignment getHorizontalAlignment()
      Returns the horizontal alignment. The default value is HorizontalAlignment.LEADING.
      Returns:
      The horizontal alignment.
    • setHorizontalAlignment

      public void setHorizontalAlignment(HorizontalAlignment horizontalAlignment)
      Sets the horizontal alignment.
      Parameters:
      horizontalAlignment - The horizontal alignment.
    • getVerticalAlignment

      public VerticalAlignment getVerticalAlignment()
      Returns the vertical alignment. The default value is VerticalAlignment.TOP.
      Returns:
      The vertical alignment.
    • setVerticalAlignment

      public void setVerticalAlignment(VerticalAlignment verticalAlignment)
      Sets the vertical alignment.
      Parameters:
      verticalAlignment - The vertical alignment.
    • doLayout

      public void doLayout()
      Lays out the text pane.
      Overrides:
      doLayout in class Container