就是使用javaSE的技术例如输入:www.baidu.com就可以跳转到百度的网站
请问下SE可以做到吗?跪求代码实现

解决方案 »

  1.   

    http://hi.baidu.com/l_rigidity/item/1dc0d695d1a0bab9cd80e515你可以参考这个看看
      

  2.   

    通过调用cmd的指令来实现打开网站
    String cmd = rundll32 + "    " + url.dll,FileProtocolHandler + "    " + url;
    Process p = Runtime.getRuntime().exec(cmd);
      

  3.   

    网页总归要在一个地方显示出来的。(刚看到你说不是在浏览器中)那么就是要做一个非常简易的浏览器。那么需要在拥有按钮和文本框的界面上,添加一个显示网页的组件。可以参考如下网址:http://www.ibm.com/developerworks/cn/java/j-lo-browser/该网址中,有一个使用SWT实现浏览的完整代码。
      

  4.   

    代码如下,贴出来供和大家一起学习(运行时需要导入swt相关的jar包):
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.browser.Browser;
    import org.eclipse.swt.widgets.Button;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Listener;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;public class SWTBrowserTest
    {
    public static void main(String args[])
    {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("SWT Browser Test");
    shell.setSize(800, 600); final Text text = new Text(shell, SWT.BORDER);
    text.setBounds(110, 5, 560, 25);
    Button button = new Button(shell, SWT.BORDER);
    button.setBounds(680, 5, 100, 25);
    button.setText("go");
    Label label = new Label(shell, SWT.LEFT);
    label.setText("输入网址 :");
    label.setBounds(5, 5, 100, 25); final Browser browser = new Browser(shell, SWT.FILL);
    browser.setBounds(5, 30, 780, 560); button.addListener(SWT.Selection, new Listener()
    {
    public void handleEvent(Event event)
    {
    String input = text.getText().trim();
    if (input.length() == 0)
    return;
    if (!input.startsWith("http://"))
    {
    input = "http://" + input;
    text.setText(input);
    }
    browser.setUrl(input);
    }
    }); shell.open();
    while (!shell.isDisposed())
    {
    if (!display.readAndDispatch())
    display.sleep();
    }
    display.dispose(); }
    }
      

  5.   

    有没有导入SWT的相关jar包??如果没有报错的话,应该是没有导入需要的jar包我导入的jar包是org.eclipse.swt.win32.win32.x86_64_3.100.1.v4236b.jar该jar包在eclipse安装目录中,我的是eclipse\plugins
      

  6.   

    按钮的事件里加上一句Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.baidu.com");就可以了。