我想让 SWT 在我运行我的应用程序的所有平台上使用 Firefox。但 SWT 当然默认在 Windows 上使用 IE。任何想法如何让 SWT 在 Windows 上使用 Mozilla。我知道我需要在机器上安装 XULRunner。
最佳答案
你问的很有趣 - 我只是需要我们的项目一样。
代码:
Bundle bundle = Platform.getBundle("org.mozilla.xulrunner"); //$NON-NLS-1$
if (bundle != null)
{
URL resourceUrl = bundle.getResource("xulrunner"); //$NON-NLS-1$
if (resourceUrl != null) {
try {
URL fileUrl = FileLocator.toFileURL(resourceUrl);
File file = new File(fileUrl.toURI());
System.setProperty("org.eclipse.swt.browser.XULRunnerPath",file.getAbsolutePath()); //$NON-NLS-1$
} catch (IOException e) {
// log the exception
} catch (URISyntaxException e) {
// log the exception
}
}
}
更多详情:http://www.eclipse.org/swt/faq.php#howusemozilla
注:我的代码与常见问题解答(不同的插件 ID)略有不同 - 我以这种方式为我工作。
关于firefox - 如何让 SWT 浏览器控件在 Windows 上使用 Mozilla 而不是 IE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2086734/