Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5063142

(Win32) Changing program focus in taskbar hides modal frames

XMLWordPrintable

    • Fix Understood
    • x86
    • windows_98



      Name: gm110360 Date: 06/14/2004


      FULL PRODUCT VERSION :
      J2SE 1.4x

      ADDITIONAL OS VERSION INFORMATION :
      Windows 98 (possibly all versions)

      A DESCRIPTION OF THE PROBLEM :
      When changing the currently-focused application in Windows (ie by clicking a different program in the taskbar) and then focusing back on a Java application, any modal dialogs that are displayed (such as JOptionPanes) will be sent to the back. This means that the program is effectively frozen to the user because they cannot see the modal dialog.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Open any window (eg a program, My Computer, etc.) that adds itself to the taskbar.
      2. Open any Java application
      3. Make your Java program display a modal dialog (such as JOptionPane)
      4. Click on the taskbar to change to the first window (eg. My Computer)
      5. Click the taskbar to change back to your Java application
      6. You will note that the modal dialog is now hidden behind your main application window.

       >>> SampleProgram.java <<<

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;

      public class SampleProgram extends JFrame{

         public SampleProgram(){

           final Frame samp = this;

           JButton button = new JButton("Open Dialog");
           button.addActionListener(new ActionListener(){
             public void actionPerformed(ActionEvent e){
               new ModalDialog(samp,true);
               }
             }
             );

           getContentPane().add(button);

           pack();
           show();

           }

         public static void main(String args[]){
           SampleProgram sp = new SampleProgram();
           }

         }



       >>> ModalDialog.java <<<

      import javax.swing.*;
      import java.awt.*;

      public class ModalDialog extends JDialog{

         public ModalDialog(Frame frm, boolean mdl){
           setModal(true);

           getContentPane().add(new JLabel("Hello"));
           pack();
           show();

           }

         }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The modal dialog should remain in front of any other dialog (ie it should remain in the same display state and ordering as before you switched application focus)
      ACTUAL -
      The modal dialog was sent to the back, behind any other windows that are opened. For example, a modal dialog was sent behind my normal interface for the program.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Alt-Tab between applications does show the modal dialog in front of the other dialogs, however clicking the taskbar does not. The application of both these 2 methods should have an identical effect.
      (Incident Review ID: 270497)
      ======================================================================

            mbronsonsunw Mike Bronson (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: