哇,那虽然比我还简单:P
// Move this
//bottomText.setText("<a href=\"http://www.yahoo.com\">Yahoo</a>");
bottomText.setEditable(false);
bottomText.setOpaque(false);
bottomText.setEditorKit(JEditorPane.createEditorKitForContentType("text/html"))
// To Here
bottomText.setText("<a href=\"http://www.yahoo.com\">Yahoo</a>");
哦,等到用户单击链接之后再打开浏览器,在我杀了你之前,大约有4个窗口在运行;)
你快到了;)
bottomText.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(e.getURL().toURI());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (URISyntaxException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
});