我需要在JLabel中为特定单词添加一个URL。
例如: JLabel是“请点击此处报告问题”
现在我的要求只是工作“点击”应该作为一个链接,而不是完整的JLabel。 我尝试将整个JLabel转换为链接。
String labeltext = "<html><font color='black'>This is where you can log your time activity for the presales process. We are constantly " +
"upgrading our presales tools, <br /> so if you have any feedback, please click <a href='#' style='color: blue;'>here</a> to send us the request.</font></html>";
JLabel lbl = new JLabel(labeltext);
lbl.addMouseListener(new MouseListener() {
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
Desktop desktop = Desktop.getDesktop();
try {
URI uri = new URI("10.5.44.108/issue.html");
desktop.browse(uri);
} catch (Exception ex) {
}
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
});
请告诉我是否有人有任何建议来实现这一目标。
提前致谢!!
最诚挚的问候, 拉夫