Re: Starting XUL from JavaXPCOM
Ray Hilton <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Message-ID | <44623C97.6030602__45351.6622110785$1147288741$gmane$org@wirestorm.net> |
Hi,
I'm actually not explicitly defining AWT or Swing, I'm just calling the
code below. Does this implement Swing under the hood? I dont really
want to have to embed XUL inside Swing windows. Ideally I would just
like to start XUL as if it was xulrunner with the ability to call
javascript from Java, or at least open windows.
I may have confused things slightly by presuming too much there, but the
only reason I wanted to get inside the main gui event thread was because
I assumed you would need to be in there to play with xpcom. It seems
that whatever thread initializes the XPCOM embedding has to be the
thread that calls appShell.run(), and as such, I'm precluded from
playing with xpcom any more once run() has been called. All I really
want to do, is open new windows :P
Any further tips you have would be greatly appreciated. I hope this
makes things a bit clearer... I'm still struggling to get my head round
how all this fits together...
Ray
------
Mozilla moz = Mozilla.getInstance();
// initialize the embedding
moz.initEmbedding(grePath, grePath, locProvider);
// component manager
componentManager = moz.getComponentManager();
appShell = (nsIAppShell) componentManager.createInstance(
NS_APPSHELL_CID, null, nsIAppShell.NS_IAPPSHELL_IID);
appShell.create(null, null);
appShell.spinup();
// get service manager
serviceManager = moz.getServiceManager();
// Now we need to get the @mozilla.org/toolkit/app-startup;1
service:
// we only use this for its nsIWindowCreator2
nsIAppStartup appStartup =
(nsIAppStartup)serviceManager.getServiceByContractID("@mozilla.org/toolkit/app-startup;1",
nsIAppStartup.NS_IAPPSTARTUP_IID);
// get the window creator interface to the app-startup service
windowCreator =
(nsIWindowCreator)appStartup.queryInterface(nsIWindowCreator.NS_IWINDOWCREATOR_IID);
// get the window-watcher service
windowWatcher =
(nsIWindowWatcher)serviceManager.getServiceByContractID("@mozilla.org/embedcomp/window-watcher;1",
nsIWindowWatcher.NS_IWINDOWWATCHER_IID);
// set our window creator (the app-startup) service
windowWatcher.setWindowCreator(windowCreator);
openWindow("chrome://rmyapp/content/launcher.xul", "launcher");
appShell.run();
------
Michal Ceresna wrote:
> On Wednesday 10 May 2006 19:31, Ray Hilton wrote:
> Hello,
>
> the nsIAppStartup.run() starts the main gui (event-dispatching) thread.
>
> How to execute some code on the gui thread depends on your widget
> system. E.g. in SWT you have Display.asyncExec(), in Swing you have
> SwingUtilities.invokeLater(), and so on.
>
> Also, one common solution is to trigger some event, e.g. set a Timer
> and execute your code in the callback.
>
> best regards,
> Michal
> _______________________________________________
> dev-tech-java mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-java
>