Append text in JLabel
hyperlink, java, jlabel, swing
Solution
- Use HTML formatting in the label by starting the text with prefix `<html><body>` (possibly add some in-line styles in the `body` opening element).
- Add each line, ending with `<br>` or `<p>` (or `<li>` if adding `<ul><li>` to the prefix).
See also How to Use HTML in Swing Components. For such gems as..
Problem
How would I go about achieving the effect of JTextArea with JLabel? I want the output to be displayed every time the button is clicked on the next line down instead of replacing what text is already there, i.e. like an append method for JLabel? I just want it to follow the same behavior as JTextArea.append. Also I want to add hyperlink to each line.