Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6829546
Votes 12
Synopsis Modal dialog causes underlying parent JFrame to be set to "Always on top".
Category java:classes_awt
Reported Against
Release Fixed
State 1-Dispatched, bug
Priority: 3-Medium
Related Bugs
Submit Date 13-APR-2009
Description
FULL PRODUCT VERSION :
JRE 6 update 12_b04

ADDITIONAL OS VERSION INFORMATION :
Windows XP PRofessional
Version 2002
Service Pack 3

A DESCRIPTION OF THE PROBLEM :
I'm having issue with the jre 6 update 12 with our Swing application. It works fine with update 11. The issue is that my JFrame is somehow getting set to be "always on top" once I've opened an closed a modal dialog from that JFrame.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Here is the steps:

1) Open a JFrame (note the "alwaysOnTop" is not set to true).
2) Click on a button which will open a modal dialog.
3) While the dialog is open click on the underlying JFrame (nothing happens as modal dialog is blocking it).
4) Now close the dialog and suddenly the parent JFrame is now set to be always on top. This won't happen if I didn't click on the parent JFrame while the dialog was open.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect the underlying parent JFrame to not be set to be "always on top".
ACTUAL -
The parent JFrame is set to be "always on top"/

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class TestTool {

    /**
     * Main.
     *
     * @param args Input arguments.
     */
    public static void main(String[] args) {
        final JFrame f = new JFrame();
        
        JButton open = new JButton("Open Dialog");
               
        JLabel lb1 = new JLabel(
        		"<html>" +
                "<ul> " +
                "Recreate always on top bug" +
        		"<li>Click on \"Open Dialog\" button</li>" +
        		"<li>Click on parent frame while the dialog is open</li>" +
        		"<li>Close the dialog</li>" +
        		"<li>Frame is now set to be always on top</li>" +
        		"</ul>" +
        		"</html>");
        lb1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
                        
        JPanel bp = new JPanel(new FlowLayout());
        bp.add(open);
        
        Box vBox = Box.createVerticalBox();
        vBox.add(lb1);
        
        open.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                JOptionPane dp = new JOptionPane("Here I am.. ");
                JDialog jdg = dp.createDialog(f, "Dialog");
                jdg.setAlwaysOnTop(true);
                jdg.setLocationRelativeTo(f);
                jdg.setVisible(true);
                
                jdg.dispose();
            }
        });
        
        Container cont = f.getContentPane();
        cont.setLayout(new BorderLayout());
        cont.add(vBox, BorderLayout.CENTER);
        cont.add(bp, BorderLayout.SOUTH);
        SwingUtilities.invokeLater(new Runnable() {
           public void run() {
               f.pack();
               f.setSize(new Dimension(300, 300));
               f.setLocationByPlatform(true);
               f.setVisible(true);
           }
        });
    }

}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
There is no workaround.

Release Regression From : 6u11
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.
Posted Date : 2009-06-23 17:20:46.0
Work Around
N/A
Evaluation
I reproduced this bug, assigned to AWT team
Posted Date : 2009-06-23 17:21:14.0
Comments
  
  Include a link with my name & email   

Submitted On 23-APR-2009
lbarowski
This happens if you click on any JFrame (doesn't have to be the parent of the modal dialog). As a workaround, any time a modal dialog is closed, for all frames in the application, if getAlwaysOnTop() returns false, do setAlwaysOnTop(true) followed by setAlwaysOnTop(false).


Submitted On 08-JUN-2009
alok_s
The suggested workaround is difficult for our application which is designed for multi-screen and has multiple frames opened at any one time. Can you please get an ETA for when this will be fixed? There is nothing obvious in the release note of jre 1.6 update 12 to suggest why it got broken. Can we have some clarity please? 


Submitted On 07-SEP-2009
alok_s
Any further update on this? Why do we have call setAlwaysOnTop(true) and then setAlwaysOnTop(false)? In any case  the getAlwaysOnTop() call returns false even for JFrame that is shown always on top.


Submitted On 13-OCT-2009
Tifosian
Thanks for the bug report..Always Reproducible !

Since getAlwaysOnTop() returns false(though frame is logically on top)..we need to call..
setAlwaysOnTop(true)  followed by setAlwaysOnTop(false) 
to ensure the old & newValues are not the same.

Regards,
Pavan



PLEASE NOTE: JDK6 is formerly known as Project Mustang