我已经搜索了很多,但发现的指导很少。有人可以指导我找到在 java swing 应用程序的 Jlist 中创建可行超链接的最佳途径吗?
最佳答案
这是一种简洁的方法。
jList1.addListSelectionListener(this);
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting())
return;
String url = (String)jList1.getSelectedValue();
//Assume browser is supported on Desktop API
Desktop.getDesktop().browse(new URI(url));
}
我在这里使用默认模型,显示的值是 URL。在 JDK 1.6 上运行
关于java - 在java中的jlist中创建超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3145610/