你可能会考虑使用JXTable和JXHyperlink(无论是在SwingX project) - 他们支持超链接中渲染,完整的HyperlinkAction由桌面(由@Andrew汤普森提到的类)的支持
忘了提,适当的渲染器被默认为类URI,一个代码段,其通过点击到含有URI的细胞触发相应的桌面行动出关闭盒安装:
// quick model which returns URI class
DefaultTableModel model = new DefaultTableModel(0, 1) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
@Override
public Class<?> getColumnClass(int columnIndex) {
return URI.class;
}
};
// fill with supported uri types
model.addRow(new Object[]{new URI("mailto:[email protected]")});
model.addRow(new Object[] {new URI("http://swingx.java.net")});
model.addRow(new Object[] {new URI("http://stackoverflow.com/questions/9031371/how-to-show-url-as-a-click-able-url-in-jeditorpane-and-allow-them-to-open-in-def")});
model.addRow(new Object[] {new URI("http://dummy.org")});
// use in JXTable
JXTable table = new JXTable(model);
// that's it :-)
补遗
忽视了你的网址+文字的要求 - 在swingx默认支持,整个小区是可点击,不仅URL的字符串表示
博尔更好地帮助越早请张贴http://sscce.org/demonstate您的问题 – mKorbel 2012-01-27 09:43:24
的可能重复[如何显示URL,如表一点击的网址,并允许他们在默认浏览器中打开?](http://stackoverflow.com/questions/9029514/how-to-show- url-as-a-click-able-url-in-table-and-allow-them-to-open-in-default-b) – trashgod 2012-01-27 12:20:30