• Post Reply Bookmark Topic Watch Topic
  • New Topic

JDialog modality issue on Win7 taskbar click  RSS feed

 
Nathan Ford
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code below is a piece of a Java App I'm working on. After starting the program, you have a JFrame that is set to FRAME.ICONIFIED, and a modal JDialog on screen. When you click the program icon in the Win XP taskbar, the parent frame remains iconified and the JDialog returns to focus which is the behavior I want. However, when clicking the program's taskbar icon on Win 7, the parent JFrame changes its state back to Normal and shows behind the app-modal JDialog. I've tried overriding the JFrame's setExtendedState() method to intercept the frame's state change with no luck.

Is there a workaround for this, or is there a flaw my logic I need to address? Thanks for any insight into this issue.


 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nathan, welcome to the Ranch! We don't have too many rules here, but we do ask that you BeForthrightWhenCrossPostingToOtherSites.
http://forums.oracle.com/forums/thread.jspa?threadID=2238140

 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried that example on my Windows 7 machine, and I get the same behaviour. I tried to use a WindowListener to iconify the frame again if it was deiconified, but that also iconified the dialog.

I tried to not call setVisible(true) on the frame until the login screen was closed, using a WindowListener to show the frame (oddly enough the windowClosed event wasn't triggered so I chose windowClosing instead). That caused the same behaviour as you have but with the frame's contents being black until the login screen was closed. So I removed the iconify(this) call in the constructor. As a result, the frame also disappears from the task bar (as it's not iconified and not visible), until you close the login screen. I don't know if that's what you want though.

My code, based on yours:
 
Nathan Ford
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:Nathan, welcome to the Ranch! We don't have too many rules here, but we do ask that you BeForthrightWhenCrossPostingToOtherSites.
http://forums.oracle.com/forums/thread.jspa?threadID=2238140



Darryl, I posted to the Oracle forums after creating the thread here to see if anyone over there had any insight into the problem. I'm more than happy to update both threads if an answer can be found.



Rob,

Thanks for looking at the problem. I tried using a WindowListener to re-iconify with the same problem you found. Unfortunately, I need the frame to be visible in the taskbar when the login dialog appears on screen, so I can't delay the frame's setvisible(true) call. Would it be easier to change the login screen to a JPanel and add it to the frame?
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Possibly yes, you could then use a CardLayout to switch the contents. Another option is turn the login screen a JFrame of its own. Initially it's the only frame you show, and when you close it you open the other frame.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!