Search code examples
javaswinguser-interfacejpaneljtextpane

Panel with line wrapping and line breaking in Java Swing


How to implement a panel that would support line wrapping and line breaking? I would only add textual labels and line breaks to this panel. The labels should flow from left to right, wrapping to the next "line" if needed. The line breaks would cause a jump to the next line. I would also like to make the panel vertically scrollable.

The solution should work in Java 5. SwingX can be used.

Clarification: The textual labels are actually JXHyperlinks (from SwingX), i.e. the panel contains clickable labels. This is the reason I cannot just use JTextArea.


Solution

  • I found JTextPane, which I had overlooked before for some reason. This class does what I need.

    Thanks for your help though. :)