如何在swing组件(如:jlabel)上设置一个超链接。就像html页面上的超链接一样!! 个位大哥大姐帮帮忙啊!·!· 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 继承JLabel,添加MouseListener,鼠标按下事件发生时Runtime.getRuntime().exec("cmd/"+ htmPath); // 只适合Windows系统 这个也可以参考下http://community.csdn.net/Expert/topic/4858/4858937.xml?temp=.8753778 JLabel linklabel=new JLabel("<html><a href='http://www.google.com'>google</a></html>"); linklabel.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ try{ Runtime.getRuntime().exec("cmd/"+"http://www.google.com"); }catch(Exception ex){ ex.printStackTrace(); } } });我这样写怎么不对啊,报异常java.io.IOException: CreateProcess: cmd/http://www.google.com error=2 粘少了一点,不好意思String url = "http://www.google.com";Runtime.getRuntime().exec("explorer " + url);或者Runtime.getRuntime().exec("cmd.exe /c start " + url); javasocket 相同的代码在不同的机器上为什么有差别 想用java来处理下面这个文本 为何还会出现类找不到的问题 麻烦问题 发几篇swing中关于JTable中的运用-2 谁能给各JSplitPane的简单的例子阿 谢谢 大家快来抢分啊! 求教虚线 的绘制方法(20) java程序如何发布(在别的机器上执行) SOS!!! 海量数据db to db 利用JDBC转移如何提高速度问题 ArrayList、List、Array、Vetor之间有什么区别? (100分贴)关于 即时通讯软件 服务器端 Socket 连接 的相关问题,完全解决另外开贴送200分
Runtime.getRuntime().exec("cmd/"+ htmPath); // 只适合Windows系统
http://community.csdn.net/Expert/topic/4858/4858937.xml?temp=.8753778
linklabel.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
try{
Runtime.getRuntime().exec("cmd/"+"http://www.google.com");
}catch(Exception ex){
ex.printStackTrace();
}
}
});
我这样写怎么不对啊,报异常java.io.IOException: CreateProcess: cmd/http://www.google.com error=2
String url = "http://www.google.com";
Runtime.getRuntime().exec("explorer " + url);
或者
Runtime.getRuntime().exec("cmd.exe /c start " + url);