JDK-4956865 : JFileChooser does not pass the right "owner" window to its dialog
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.1
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-11-19
  • Updated: 2004-09-13
  • Resolved: 2004-09-13
Related Reports
Relates :  
Description

Name: gm110360			Date: 11/19/2003


FULL PRODUCT VERSION :
c:\>java -version
java version "1.3.1_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_09-b03)
Java HotSpot(TM) Client VM (build 1.3.1_09-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
In JFileChooser, the code in showDialog(Component,String) creates a dialog to show to the user.

  To create a dialog, one needs the "owner" of the dialog, the owner can be a frame or another dialog.

But in showDialog, the owner is found with:

     Frame frame = parent instanceof Frame ? (Frame) parent
     : (Frame)SwingUtilities.getAncestorOfClass(Frame.class, parent);

so even if the JFileChooser is invoked from a component inside a modal dialog started from a Frame, the frame will be returned as the owner whereas one may expect the owner to be the Dialog.

In showDialog, the code should look for a Dialog first, then for a frame.

FYI, the JOptionPane does it better by looking for the closest window in the ascendant hierarchy.

Note this issue is not about asking for "modal dialog should come to the front
when taskbar icon is clicked".

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On Microsoft Windows 2000, create a frame with one button. When the button is clicked, open a dialog with the frame as the owner. In the dialog, have a button which open a JFileChooser using showOpenDialog. While the chooser is visible, open another application (Explorer for example). The java gui becomes hidden by the other application. Click on the taskbar icon to bring the java application back, the JFileChooser dialog should be made visible.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the JFileChooser dialog to be made visible when I click on the taskbar button.
ACTUAL -
The main frame of the application gets activated but the application seems to be blocked as it does not respond to user inputs. Using alt-tab to bring the application to the front brings back the JFileChooser dialog to front.

REPRODUCIBILITY :
This bug can be reproduced always.
(Incident Review ID: 226280) 
======================================================================

Comments
EVALUATION This bug is not reproducible in 1.4.2 or later. ###@###.### 2004-09-13 Correction: This bug was fixed by fix for bug 4759934 in 1.5.0. ###@###.### 2004-09-17
13-09-2004