I want to display a list of links in a java component, doesn t matter what component it is. By links I mean URLs of some sites. Those links can be clicked and doing so opens chosen URL in the default web browser for example google chrome / firefox ( I don t want to display web pages in java, only links ).
I already know how to display single link, but I am having problems with display a list of links. I tried to do it like this :
public void appendTextToJEditorPane(String text) {
try {
Document doc = jEditorPane1.getDocument();
String newLine = "
";
String url = "<html><a href=" + text + ">" + text + "<//a><//html>.";
doc.insertString(doc.getLength(), url, null);
doc.insertString(doc.getLength(), newLine, null);
} catch (BadLocationException exc) {
exc.printStackTrace();
}
}
appendTextToJEditorPane("http://google.pl");
appendTextToJEditorPane("http://wp.pl");
appendTextToJEditorPane("http://onet.pl");
但是,由于在html关口存在“/”的问题,它没有工作。 我在JEditorPane获得通俗的文本。 如何适当调整联系?