• Post Reply Bookmark Topic Watch Topic
  • New Topic

Screen Focus handling across Two Standalone Swing Applications

 
Bobby Jagan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am using two different standalone Swing applications(Swing Appln1 and Swing Appln 2). Both of my Swing applications can communicate/interact with each other. Say for instance, i can pass a few values from SwingAppln 1 to SwingAppln2 and do some manipulations/data processing in Swing Appln 2.

The processing part is all working fine and im facing some problems in managing the focus of screens of these two Swing applications Appln 1 and Appln 2.

And my requirement here is:

when input values pass from Appln1 to Appln2, the data is processed in a seperate second screen i.e., Screen no:2 of Swing Appln2.

When this process is happening the controls in my first application window all are disabled and I am fine and OK with this.

What i require at this moment is, my Screen2 of Appln2 should come to the front(should be the one to have the focus and visble to the users) so that the users can key in some additional input values and submit the screen.

Once the processing is completed in Screen2 of Appln 2 it should lose its focus and shud go to the background and the first Appln 1 should gain the focus and should be displayed to the users in the front.

This should happen automatically.

i used toFront() funtion to bring the screen2 of application2.
But it does not work.
The controls used in my program is JPanel.

Please advice on how to implement this.
 
Campbell Ritchie
Marshal
Posts: 52531
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.
Thank you for adjusting your display name
[ February 29, 2008: Message edited by: Campbell Ritchie ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If these truly are completely separate swing applications (i.e. they run in different JVMs, not just different frames within the same JVM) then toFront() isn't going to work - that's for managing frame order of multiple frames within one JVM.

You could manage frames across JVMs by using JNI to call native libraries (I've seen this done in Windows before, and assume that there are comparable libraries on other platforms that can handle this.) - but then you have to worry about all kinds of things like getting the process of your java program and the native handle of your frame.

I'd really suggest seeing if you could run both of the applications in one JVM if possible - it's probably the easier option.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!