在JAVA运行的程序中的一个菜单项上设置超链接。。怎么写?
谢谢!

解决方案 »

  1.   


    final String google = "www.google.cn";
    String news = "<html><a href=" + google + ">www.google.cn</a></html>";
    JMenuItem jMenuItem = new JMenuItem(news);
    jMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {
    // 你所要实现的代码 Desktop desktop = Desktop.getDesktop(); //链接到google
    try {
    desktop.browse(new URI(google));
    } catch (IOException e1) {
    e1.printStackTrace();
    } catch (URISyntaxException e1) {
    e1.printStackTrace();
    }
    } }); m1.add(jMenuItem);