I am trying to embed a web browser inside a java application. Unfortunately it has to be in the application and not open a browser.
I have found org.eclipse.swt.browser. I am using this browser to display 3D models and when I click in the browser and drag my mouse I should be able to rotate it. Is there an option to enable this or anything I can do to fix this?
You can use this site for an example: https://a360.autodesk.com/viewer
When you open the site there are models that can be rotated with left click or moved with right click.
But when I open the same page using swt.browser I can't neither rotate or drag the model.
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class BrowserClass {
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Browser Example");
shell.setSize(1300, 800);
final Browser browser = new Browser(shell, SWT.NONE);
browser.setBounds(5, 5, 1275, 750);
shell.open();
browser.setUrl("https://a360.autodesk.com/viewer");
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
I have attempted removing display.sleep() and I have tried using setTouchEnabled(true) but I can only use it on shell and browser. The display always has it set to false could the issue be here?
答案 0 :(得分:1)
Using SWT.NONE
as the style of the Browser
on Windows will use Internet Explorer as default. It looks like IE doesn't support whatever magic is used to show the animation.
Try using SWT.MOZILLA
to force SWT to use XULRunner as a backend.
Here's some more information on how to do that:
How do I explicitly use Mozilla as the Browser's underlying renderer?