Re: Using the dom of mozilla with javaxpcom and the w3c connector
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <1158516594.621626.25650__48577.1020678387$1158516636$gmane$org@m7g2000cwm.googlegroups.com> |
This is about the minimum to get the mozilla dom:
Thanks to Miroslav Penkov
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.MozillaBrowser;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.mozilla.xpcom.nsIDOMDocument;
public class Test {
public static void main(String args[]) {
Display display = new Display();
Shell shell = new Shell(display);
final MozillaBrowser browser = new MozillaBrowser(shell,
SWT.BORDER);
browser.setUrl("http://www.google.com");
browser.addProgressListener(new ProgressListener() {
public void changed(ProgressEvent event) {
}
public void completed(ProgressEvent event) {
nsIDOMDocument doc = browser.getDocument();
System.out.println(doc);
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}
Can Candan wrote:
> Hi all,
>
> Can someone show me how to embed mozilla, so that I can load a page and
> access its dom using the W3C Connector, in the simplest possible way?
>
>
> I have tried the following using eclipse ATF classes
>
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.open ();
> org.eclipse.swt.browser.MozillaBrowser mb = new MozillaBrowser(shell,
> SWT.NONE);
> mb.setUrl(" http://www.google.com");
>
> setUrl requests the page, I sniffed network activity the page is being
> transmitted.
> But when I set a breakpoint at that location thereby giving it time to
> complete loading and then execute
>
> mb.getUrl();
>
> I get about:blank instead of the google url.