JDK-4336913 : On Win32, disable parent window controls while modal dialog is being created.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.0,1.3.1_06,1.4.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,windows_nt,windows_2000
  • CPU: x86
  • Submitted: 2000-05-10
  • Updated: 2003-03-14
  • Resolved: 2003-03-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Duplicate :  
Duplicate :  
Description
While a modal dialog is being created, the parent frame's controls (such as close, move, resize) are still active. To match Windows convention, it should be disabled on Windows. See the attached program below.

If we have a dialog that brings out another modal dialog when clicking
on a button, JDK will ensure that all the UI
components in the first dialog cannot be activated while the second
dialog is been constructed. However, it is still possible to press the
Window's system close button ( i.e. the "X" button on the top right hand
corner) of the first dialog. As a result, the first dialog gets
dismissed before the second dialog is shown.

================================
// TestDialog.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class TestDialog extends JDialog
{
    JFrame frame;
    static int i = 0;
    public TestDialog( JFrame f, boolean wait )
    {
        super( f, true );
        frame = f;
        addWindowLisnener( new WindowAdapter() {
            public void windowClosing( WindowEvent event )
            {
                System.out.println( "Disposing " + getTitle() );
                setVisible( false );
                dispose();
            }
        });
        setTitle( "Dialog number " + ++i );
        setLocation( new Point( i * 20, i * 20 ) );
        setSize( new Dimension( 500, 200 ) );
        JButton btn2 = new JButton( "<html><center><strong>Press me to launch another modal dialog<br>that takes 5 seconds to contruct." );
        btn2.addActionListener( new ActionListener() {
            public void actionPerformed( ActionEvent event )
            {
                TestDialog dlg2 = new TestDialog( frame, true );
                dlg2.show();
            }
        });
        JButton btn3 = new JButton( "<html><center><strong>You cannot press me when a modal dialog is being construction<br>but you can press the X button above." );
        btn3.addActionListener( new ActionListener() {
            public void actionPerformed( ActionEvent event )
            {
                JOptionPane.showMessageDialog( frame, "You pressed me" );
            }
        });
        JPanel panel = new JPanel( new BorderLayout() );
        panel.add( BorderLayout.NORTH, btn2 );
        panel.add( BorderLayout.SOUTH, btn3 );
        getContentPane().add( panel );

      if( wait )
        {
            try
            {
                Thread.currentThread().sleep( 5000 );
            }
            catch( InterruptedException x )
            {
            }
        }
    }

    public static void main( String[] args )
    {
        final JFrame frame = new JFrame();
        frame.setSize( new Dimension( 500, 100 ) );
        JButton btn1 = new JButton( "<html><strong>Press me to launch a Modal Dialog" );
        btn1.addActionListener( new ActionListener()
        {
            public void actionPerformed( ActionEvent event )
            {
                TestDialog dlg1 = new TestDialog( frame, false );
                dlg1.show();
            }
        });
        frame.getContentPane().add( btn1 );
        frame.show();
    }
}



Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b03
24-08-2004

EVALUATION Name: osR10079 Date: 12/20/2002 AWT ensures that all UI components of toplevels which are not in new modal dialog heirarchy will be unaccessible AFTER this modal dialog will be shown. AWT says nothing about period of creation of that dialog. User is unable to press any buttons in the first dialog in the test because corresponding mouse event will be dispatched after second modal dialog will be shown (this dialog is showing on the event dispatch thred) and this event will be consumed to prevent from showing one more modal dialog. But pressing of closing button (X) produce WINDOW_CLOSING event which won't be consumed. So, i think the problem described in this bugreport is not a bug. ###@###.### 2002-12-20 ====================================================================== Name: osR10079 Date: 02/11/2003 I think if we fix the problem described in bugreport it doesn't harm anyone but make AWT's behavior more consistent. ###@###.### 2003-02-11 ======================================================================
11-02-2003