by
2
6
204k
0
Top 1% !
Popular
Pearl of Wisdom
Easy-to-find
Specified
OpenSource
Popularity: 7838th place

Published on:

InputType0WindowEvent
JVMjre7
LanguageJava
LicenseMIT_X11
MethodNameopen
OSLinux
OSWindows
OutputTypevoid

Embed a browser into SWT Dialog and manage the firing of popups from links in the displayed page

This is how to manage an embedded browser.
Note: unfortunately this seems not working on some versions of Mac OS X.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/121585/Embed-a-browser-into-SWT-Dialog-and-mana?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
try { Browser browser = new Browser(this, SWT.NONE); browser.setJavascriptEnabled(true); browser.setUrl("www.myurl.com"); browser.addOpenWindowListener(new OpenWindowListener() { public void open(WindowEvent event) { log.debug("Opening browser:" + event); new Thread( new Runnable() { public void run() { log.debug("some stuff t do here..."); } }).start(); final Shell shell = new Shell(event.display); shell.setText("My Browser page"); shell.setLayout(new FillLayout()); event.browser = new Browser(shell, SWT.NONE); shell.open(); event.browser.addCloseWindowListener(new CloseWindowListener() { @Override public void close(WindowEvent event) { log.debug("closing"); shell.setVisible(false); } }); } }); } catch (Throwable t) { //on some architecture seems that SWT Browser is not working... log.warn("Cannot display SWT Browser"); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus