0

I have two Java applications running. One is the mother system and another is a sub application. Both using JFrame. Both has an alwaysOnTop(True) behaviors. I have no access on the mother system and it is overriding the alwaysonTop behavior of my sub application.

I tend to invoke requestFocus() on method calls. That seems to suffice in most cases but when idle or start up, the sub application sometimes dont get the focus.

How do I override the mother application's always on top when I do not have access to the mother application?

I also did this

addWindowListener(new WindowAdapter() {
    @Override
    public void windowOpened(WindowEvent e) {
        requestFocus();

    }

    @Override
    public void windowClosed(WindowEvent e) {

    }
mKorbel
  • 109,525
  • 20
  • 134
  • 319
Philip Morris
  • 459
  • 1
  • 9
  • 26
  • This is OS specific behavior, but you could try using `toFront` – MadProgrammer Aug 27 '15 at 03:40
  • Iterate the [available windows](http://docs.oracle.com/javase/8/docs/api/java/awt/Window.html#getWindows--) find the one that you refer to as 'mother' and call `setAlwaysOnTop(false)` on it. See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson Aug 27 '15 at 03:48
  • @andrewThompson i do not have access to the mother app code. – Philip Morris Aug 27 '15 at 03:51
  • Is while(isVisible){ toFront() } good? – Philip Morris Aug 27 '15 at 03:52
  • *"i do not have access to the mother app code."* You don't need access to the code of `MotherFrame` to do what I suggested. Are you saying the two frames do not run in the same JVM? – Andrew Thompson Aug 27 '15 at 03:53
  • *"Is while(isVisible){ toFront() } good?"* I'd describe that is an 'ugly hack' and in no way 'good'. It would seem to block the EDT. – Andrew Thompson Aug 27 '15 at 03:54
  • *"Is while(isVisible){ toFront() } good?"* Tip: Add @MadProgrammer (or whoever, the `@` is important) to *notify* the person of a new comment. – Andrew Thompson Aug 27 '15 at 15:18

0 Answers0