Make XUL application visible
[email protected] Tue, 17 Mar 2009 06:43:41 -0700 (PDT)
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <3cd240da-1bc7-4f41-8078-2edff0a5d136__37525.8681517609$1237297627$gmane$org@v38g2000yqb.googlegroups.com> |
Hi
I am using Java XPCOM and xulrunner-1.8.0.4. Im trying to embed
xulrunner in Java, as I am sure many people are. I seem to be stuck, I
believe my Java code is starting xulrunner correctly, but I see no
visible window. Should the window be visible?
The code:
// First, get the event queue service. This handles all event queues
in
// XPCOM.
nsIEventQueueService eventQueueServive = (nsIEventQueueService)
serviceManager
.getServiceByContractID("@mozilla.org/event-queue-service;1",
nsIEventQueueService.NS_IEVENTQUEUESERVICE_IID);
// Next, we want to get the UI thread, since we want to open a
window.
// There is a static variable on the
// nsIEventQueueService that contains the id of the special UI event
// queue.
nsIEventQueue eventQueue = eventQueueServive
.getSpecialEventQueue(nsIEventQueueService.UI_THREAD_EVENT_QUEUE);
// Now create a proxy for the proxy object manager.
nsIProxyObjectManager proxy = (nsIProxyObjectManager)
componentManager
.createInstanceByContractID("@mozilla.org/xpcomproxy;1", null,
nsIProxyObjectManager.NS_IPROXYOBJECTMANAGER_IID);
// and use the proxy object manager to create a proxy for the
// nsIWindowWatcher instance we created above.
nsIWindowWatcher windowProxy = (nsIWindowWatcher) proxy
.getProxyForObject(eventQueue,
windowWatcher.NS_IWINDOWWATCHER_IID, windowWatcher,
nsIProxyObjectManager.INVOKE_SYNC);
// now we use the proxy to call the method as usual.
nsIDOMWindow domWindow = windowProxy.openWindow(null,
"chrome://myapp/content/main.xul", "bob", "centerscreen", null);
Cheers
Greg