BasicService.showDocument(url) loses application focus to browser
Hi
I'm using Webstart to run a swing client application that displays a listbox of headings (urls) . The use case is that a user should be able to select a headline in the listbox and see the corresponding webpage displayed in the browser.
This works fine on XP/Vista/2000 with IE5/6/7 and Firefox 2.0.
However there is a problem, once the first webpage is displayed the browser becomes the foremost application, and the user has to use the mouse to restore focus to the swing app. This is annoying as the main use case is for the user to be able to scroll through stories using the cursor keys, while seeing the stories update in the browser.
I've tried varients of:
BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
bs.showDocument(url);
this.toFront();
and
SwingUtilities.invokeLater(this.toFront()); //simplified, it built a thread to invoke
but to no avail.
Can anyone advise how to restore control to the swing app and just have the browser act as a "slave"?
Regards
Dan
[1097 byte] By [
danhanleya] at [2007-11-27 4:42:32]

# 2
Thanks Andrew... I'll see if Ican get JDIC to work, trying to run the demo on my vista box gives:
Loaded by JavaWebStart,version is javaws-1.6.0
running path C:\Users\Dan\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\45\61c1446d-31e4d4b4-n
nativeLibLoaded false
load jdic...
loading jdic in WebBrowserUtil
*** Jtrace: Envent Thread run once!
*** Jtrace: Msg Client new once!
*** Jtrace: Using browserManager null
*** Jtrace: Default browserManager is used.
nativeLibLoaded true
*** Jtrace: No browser is selected as active,you must specify one by setActiveEngine()!
Exception in thread "EventThread" java.lang.NullPointerException
at org.jdesktop.jdic.browser.internal.MsgClient.<init>(MsgClient.java:101)
at org.jdesktop.jdic.browser.internal.NativeEventThread.run(NativeEventThread.java:86)
fasjflkasdjf
# 3
> ..I'll see if Ican get JDIC to work, trying to run the demo on my vista box gives:
...
> *** Jtrace: No browser is selected as active,you must specify one by setActiveEngine()!
That is unfortunate. I checked the link after you
reported back and it worked for me (Win XP Pro
with Java 6). OTOH I went searching on that
string and found..
http://forums.java.net/jive/thread.jspa?threadID=13873
http://forums.java.net/jive/thread.jspa?messageID=168979
Either of these threads might relate to the
problem. What is your default browser?
# 5
try 6u1.
Web Start in 1.6.0 does not implement Desktop.browse(), to use it"s own BrowserManager (other than the default). it is implemented in 6 update 1, to call JNLP BasicService API to show the doc.
This happens somewhat asynchronously, which causes the Windows ActiveWindow to become the browser.
/Andy