日期:2014-05-20  浏览次数:20643 次

求大神们帮忙
public JLabelDemo() throws Exception{
super();
this.setTitle("哈哈");
this.setBounds(100, 100,500,500);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//System.out.println("hhh");
JLabel jLabel=new JLabel();
jLabel.setToolTipText("上海海洋大学");
jLabel.setDisplayedMnemonic('0');
jLabel.setHorizontalAlignment(SwingConstants.CENTER);
jLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
jLabel.setText("<html><body><font size=10pt><a href=http://www.baidu.com>上海海洋大学</a></font></body></html>");
jLabel.addMouseListener(new java.awt.event.MouseAdapter(){

public void mouseReleased(MouseEvent e){
jLabel_mouseReleased(e);
      }
void jLabel_mouseReleased(MouseEvent e){
try {
     System.out.println("");
Runtime.getRuntime().exec("cmd/c start http://www.baidu.com");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();}
}
}
);
this.add(jLabel);
}调试出现如下错误

电脑是win7 32位系统
exception

------解决方案--------------------
这样玩就好..

try {
Runtime.getRuntime().exec(new String[]{"cmd","/c","start http://www.baidu.com"});
} catch (IOException e) {
e.printStackTrace();
}