swt实现在c/s界面中打开web网页

需要XULRunner支持
windows的xulrunner只是一个压缩文件,不是安装文件
e:\xulrunner表示的是xulrunner的解压地址

`import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.TitleEvent;
import org.eclipse.swt.browser.TitleListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Test1 {

    static{
     System.setProperty("org.eclipse.swt.browser.XULRunnerPath", "e:\\xulrunner"); 
    } 
    public static void main(String[] args) {

        Display display = new Display (); 
        final Shell shell = new Shell (display); 
        FillLayout layout = new FillLayout(); 
        shell.setLayout(layout); 

        Browser browser = new Browser(shell, SWT.MOZILLA); //1
        browser.addTitleListener(new TitleListener(){  //2
            public void changed(TitleEvent event) { 
                shell.setText(event.title); 
            } 
        }); 
        browser.setUrl("http://192.163.20.17:8080/20150509SSH_Study/index.jsp"); //3
        shell.open (); 
        while (!shell.isDisposed ()) { 
            if (!display.readAndDispatch ()) display.sleep (); 
        } 
        display.dispose ();
    }
}

你可能感兴趣的:(swt-html)