如题

解决方案 »

  1.   

    给这个button加一个点击鼠标事件,然后在事件里调用如下函数。其中C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE 为ie的安装路径,呵呵。OVERRuntime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE http://www.csdn.net");我的测试代码如下,没有写BUTTON。
    public class TestOpenIE {    public static void main(String[] args) {
            try {
                Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE http://www.csdn.net");
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println("Successful");
        }}
      

  2.   

    运行这段applet,即可得到你要的效果
    import java.awt.Container;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;import javax.swing.JApplet;
    import javax.swing.JButton;public class ButtonOpenWebpage extends JApplet {
    JButton jb = new JButton("打开我要的地址!"); ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent e) {
    try {
    Runtime
    .getRuntime()
    .exec(
    "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE http://www.csdn.net");
    } catch (Exception ef) {
    ef.printStackTrace();
    } }
    }; public void init() {
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    jb.addActionListener(al);
    cp.add(jb);
    }
    }
      

  3.   

    上述都只能调用ie,用下面方法可以调用系统的默认浏览器,比如说
    我的默认浏览器是opera,那么它就调用opera打开网址
    Runtime.getRuntime().exec("rundll32 url.dll ,FileProtocolHandler http://www.csdn.net");
      

  4.   

    http://community.csdn.net/Expert/topic/4084/4084877.xml?temp=.2726709