I searched how to make clickable links in JEditorPane
, and I found this question:
Is it possible to create programs in Java that create text to link in Chrome?
It was very useful, but my code uses a repetition statement to add links in a loop:
JEditorPane jep = new JEditorPane();
jep.setContentType("text/html");
jep.setEditable(true);// Because replaceSelection can't work with disabled edit
for ( int i = 1; i <= 3; i++ ){
jep.replaceSelection(
"Welcome to <a href='https://stackoverflow.com/'>StackOverflow i </a>.");
}
jep.setEditable(false);
Now it shows me just text without clickable links. How am I going to make it right? I really need replaceSelection
method.