java - New window appears sandwiched between parent and child JFrame/JDialog -


new windows other processes open behind focused jdialog child in front of jdialog parent. expect new windows appear in front of child. none of these windows declared on top.

picture

  • see app 3 between app 2 windows
  • does not matter behind app 1 - on top, expected

3 between app 2 windows

actual order

jdialog (app 1 - on top) jframe (app 2 non modal dialog child of app 2 main) jdialog (app 3) <=== new window should appear on top of app 2 jframe (app 2 - main window) 

expected order

jdialog (app 1 - on top) jdialog (app 3) <=== new window should appear on top of app 2 jframe (app 2 non modal dialog child of app 2 main) jframe (app 2 - main window) 

this problem happens if

  • there existing window process declared always-on-top, doesn't have java, used java in sample below - issue happens if select on top firefox, gnome-terminal etc.
  • the new window opened in position behind on top application. again, doesn't have java application, repeated firefox, gnome-terminal.
  • redhat linux 6. not repeatable on ubuntu 16.04 or windows 7

if window opened right (change newwindow.setbounds(**370**, 20, 0, 200)) in sample below, not behind on top window appears in front of child.

3 opens above 2

to clear, problem occurs between 3 separate applications, simplicity i've recreated below single java application.

public class combined {     public static void main(string[] args) throws exception {          jframe aot = new jframe("app 1 - on top");         aot.setalwaysontop(true);         aot.setbounds(50, 50, 300, 40);         aot.setvisible(true);          jframe frame = new jframe("app 2 - main window");         frame.setdefaultcloseoperation(windowconstants.exit_on_close);         frame.setbounds(100, 100, 300, 200);         frame.setvisible(true);          jdialog child = new jdialog(frame, "app 2 - non-modal child dialog (child)");         child.setbounds(150, 150, 300, 200);         child.setvisible(true);          thread.sleep(1000);         jframe newwindow = new jframe("app 3");         newwindow.setdefaultcloseoperation(windowconstants.exit_on_close);          newwindow.setbounds(200, 20, 300, 200);         // newwindow.setbounds(370, 20, 300, 200);          newwindow.setvisible(true);     } } 

is there option can applied jdialog child such allows windows appear above it. background i'm developing "app 2" application, other parts , redhat linux installation managed other third-parties, cannot changed easily.

tried using strict/smart window manager options, no difference in behaviour

gconftool-2 --set /schemas/apps/metacity/general/focus_new_windows --type string smart gconftool-2 --set /schemas/apps/metacity/general/focus_new_windows --type string strict 

hacky solutions

  • show, hide , show app 3 window again. in case appears above "app 2 child" correctly, although causes noticable flicker

code

newwindow.setvisible(true); newwindow.setvisible(false); newwindow.setvisible(true); 

in summary there no nice solutions linux windows management specific issue. can done banish always-on-top windows application. best practice anyway, difficult when dealing legacy codebases.

the other solution of desparation setvisible() dance.

newwindow.setvisible(true); newwindow.setvisible(false); newwindow.setvisible(true); 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -