在SWT浏览器中运行JQuery脚本
我正在开发一个带有嵌入式SWT浏览器的Java应用程序。我想在SWT浏览器上运行一个jquery脚本。我已经将jquery库文件放在项目的src文件夹中。这里是程序。
import org.eclipse.swt.SWT; import org.eclipse.swt.browser.AuthenticationEvent; import org.eclipse.swt.browser.AuthenticationListener; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.browser.ProgressEvent; import org.eclipse.swt.browser.ProgressListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.*; public class Dummy3 { static int x=1; public static void main(String args[]) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); //static int x=1; final Browser browser = new Browser(shell, SWT.NONE); final String s= ""+ ""+ "The jQuery Example "+ ""+ ""+ // ""+ ""+ ""+ ""+ "Click on this to see a dialogue box."+ ""+ ""+ "" ; browser.setText(s); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }
问题是因为脚本无法找到lib>这里有一个解决方案在RAP中的SWT Browser小部件中使用JavaScript显示本地HTML文件 。
我刚刚通过更改src来解决这个问题
从W3Schools.com获取此链接“试用编辑器”