JDK-4636311 : Hang in JDK1.4 rc when showing a modal dialog from a Runnable
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2002-02-12
  • Updated: 2002-10-18
  • Resolved: 2002-10-18
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
1.4.2 mantisFixed
Related Reports
Relates :  
Description
I filed this bug based on an email I received about feedback on JDK1.4 RC.  

I filed the platform as generic because that information was not given.  

There's another problem I've been having w/ modal dialogs that appears
in JDK1.3.1 & JDK1.4-rc1, but does not appear JDK1.3.0 and did not
appear in JDK1.4-beta3.  Basically the modal dialog comes up, but all of
the components within the dialog are not useable (it's like there's a
glass pane that covers the dialog making the components unusable), only
the dialog close box takes events.  

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


public class DialogBug extends JFrame implements ActionListener {

    private DialogBug bug;

    public DialogBug() {
        super("Frame");
        bug this;
        getContentPane().setLayout(new FlowLayout());
        JButton b new JButton("Press Me");
        b.addActionListener(this);
        getContentPane().add(b);
        Dimension d Toolkit.getDefaultToolkit().getScreenSize();
        setBounds(d.width/2-120, d.height/2-160, 200, 200);
        addWindowListener(new WindowAdapter() {
                              public void windowClosing(WindowEvent e) {
                                  System.exit(0);
                              }
                          });
        setVisible(true);
    }

    public void actionPerformed(ActionEvent e) {
        new MyDialog();
    }


    public class MyDialog extends JDialog implements ActionListener {

        public MyDialog() {
            super(bug, "Modal Dialog", true);
            getContentPane().setLayout(new FlowLayout());
            JButton b new JButton("Threaded");
            b.addActionListener(this);
            getContentPane().add(b);
            b new JButton("Not Threaded");
            b.addActionListener(this);
            getContentPane().add(b);
            Rectangle r bug.getBounds();
            setBounds(r.x, r.y, 200, 200);
            setVisible(true);
        }

        public void actionPerformed(ActionEvent e) {
            String command e.getActionCommand();
            if (command.equals("Threaded")) {
                //
                // The problem appears when threaded otherwise ok...
                //
                Runnable runner new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(null, "Try to press OK button!!!");
                    }
                };
                new Thread(runner).start();
            } else {
                JOptionPane.showMessageDialog(null, "Try to press OK button!!!");
            }
        }
    }


    public static void main(String args[]) {
        new DialogBug();
    }
}


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

EVALUATION Commit to fix in mantis (hang). ###@###.### 2002-02-11 Name: osR10079 Date: 07/25/2002 The problem is as follows: when the first modal dialog (MD1) is shown on EventDispatchThread, AWT starts discard all events which aren't targeted to MD1's hierarchy. But the second modal dialog (MD2) is shown not on the EDT, and this doesn't affect started filter. MD1's hierarchy doesn't include MD2, thus all events which are targeted to MD2 is dicarded. ###@###.### July 25, 2002 ======================================================================
24-08-2004

SUGGESTED FIX Name: osR10079 Date: 10/03/2002 To fix this problem we should start new filtering message pump for every modal dialog, not only if it's shown on EDT. ###@###.### 2002-10-04 ------- Dialog.java ------- *** /tmp/dTXaGBj Thu Oct 3 08:10:09 2002 --- Dialog.java Thu Oct 3 08:06:38 2002 *************** *** 532,538 **** KeyboardFocusManager.getCurrentKeyboardFocusManager(). enqueueKeyEvents(time, predictedFocusOwner); ! if (Toolkit.getEventQueue().isDispatchThread()) { /* * dispose SequencedEvent we are dispatching on current * AppContext, to prevent us from hang. --- 532,550 ---- KeyboardFocusManager.getCurrentKeyboardFocusManager(). enqueueKeyEvents(time, predictedFocusOwner); ! Runnable pumpEventsForHierarchy = new Runnable() { ! public void run() { ! EventDispatchThread dispatchThread = ! (EventDispatchThread)Thread.currentThread(); ! dispatchThread.pumpEventsForHierarchy(new Conditional() { ! public boolean evaluate() { ! return keepBlocking && windowClosingException == null; ! } ! }, Dialog.this); ! } ! }; ! ! if (EventQueue.isDispatchThread()) { /* * dispose SequencedEvent we are dispatching on current * AppContext, to prevent us from hang. *************** *** 545,559 **** currentSequencedEvent.dispose(); } ! EventDispatchThread dispatchThread = ! (EventDispatchThread)Thread.currentThread(); ! dispatchThread.pumpEventsForHierarchy(new Conditional() { ! public boolean evaluate() { ! return keepBlocking && windowClosingException == null; ! } ! }, this); } else { synchronized (getTreeLock()) { while (keepBlocking && windowClosingException == null) { try { getTreeLock().wait(); --- 557,569 ---- currentSequencedEvent.dispose(); } ! pumpEventsForHierarchy.run(); } else { synchronized (getTreeLock()) { + Toolkit.getEventQueue(). + postEvent(new PeerEvent(this, + pumpEventsForHierarchy, + PeerEvent.PRIORITY_EVENT)); while (keepBlocking && windowClosingException == null) { try { getTreeLock().wait(); ======================================================================
24-08-2004