Swingの文字表示
jTextField1.setBounds(new Rectangle(63, 44, 244, 23));
jScrollPane1.setBounds(new Rectangle(40, 114, 156, 120));
jScrollPane1.getViewport().add(jTextArea1, null);
String st="<html><body><h2>hello</h2>H<sub>2</sub>O</body></html>";
jEditorPane1.setEditable(false);
jEditorPane1.setContentType("text/html");
jEditorPane1.setText(st);
あるいは、htmlのファイル(forst.html)を setPage でそのまま表示できます。 try{
jEditorPane1.setPage(getCodeBase()+"first.html");
} catch (Exception err)
{System.out.println("error setpage:"+err.toString());
}
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return;
String url = e.getURL().toString();
//jEditorPane1.setText(url);
try { jEditorPane1.setPage(url); } catch(Exception err) {}
}
hyperlinkUpdate は インターフェース HyperlinkListener のメソッドで、