Use the StringEscapeUtils
class from the Apache Commons library, to escape your HTML, then put it inside <html><body>
to tell Swing to display the result as HTML.
import org.apache.commons.lang3.StringEscapeUtils;
String escapedHtml = StringEscapeUtils.escapeHtml4(htmlToDisplay);
DefaultMutableTreeNode myLeafNode =
new DefaultMutableTreeNode("<html><body>" + escapedHtml + "</body></html>");