JDK-4044219 : JDK1.1.1 dialog modality not consistent across platforms
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: generic
  • Submitted: 1997-04-09
  • Updated: 1997-12-23
  • Resolved: 1997-12-23
Related Reports
Duplicate :  
Description
JDK 1.1.1 AWT is not consistent in its application of window modality

If I create an application with two top-level windows, and have one
of them be the parent to a pop up a modal dialog should I be able to still interact with the other window?

On Solaris I can
on win32 I can't

It is surely a bug that the behaviour is inconsistent across platforms

I find it a little surprising that you can interact with other windows on
Solaris/Motif since Motif's relevant modality definition is APPLICATION_MODAL,
 which you would expect to produce the same behaviour as on win32

Here is a simple test case
//DialogTest.java
import java.awt.*;

public class DialogTest extends Dialog
{

	public DialogTest(Frame parent, String title) {
                     this(parent,title,true);
                }

	public DialogTest(Frame parent, String title, boolean modal)
	{
		super(parent, title, modal);

		this.parent = parent;
		setLayout(new BorderLayout());

		Panel buttonPanel = new Panel();
		closeButton = new Button("Close");
		buttonPanel.add(closeButton);
		add("Center", buttonPanel);

		pack();
	}

	public boolean action(Event e, Object arg)
	{
		if (e.target == closeButton)
		{
                 Dialog dialog = null;
                 Component c = (Component)e.target;

                 while ( c!=null && !(c instanceof Dialog))
                         c = c.getParent();

                 if (c != null) dialog = (Dialog)c;

                 if (dialog == null)
                      return false;

		 dialog.setVisible(false);
		 dialog.dispose();
  		 return true;
		}

		return false;
	}

	public static void main(String args[])
	{
		Frame f = new ExitFrame("Dialog parent");
		DialogTest dlg = new DialogTest(f, "Modal Dialog");
		f.resize(200,200);
		f.setVisible(true);

                Frame f2 = new ExitFrame("Other window");
                f2.resize(100,300);
                f2.setVisible(true);


		dlg.setVisible(true);
	}



	Button anotherButton;
	Button closeButton;
	Frame parent;
}

class ExitFrame extends Frame {

    public ExitFrame(String title) {
             super(title);

              add("South",new Button("Exit"));
    }

    public boolean action(Event evt, Object what) {
          if (evt.target instanceof Button) {
                System.exit(0);
                return true;
           }
           else
              return false;
    }
}

Comments
PUBLIC COMMENTS JDK 1.1.1 AWT is not consistent in its application of window modality If I create an application with two top-level windows, and have one of them pop up a modal dialog should I be able to still interact with the other window? On Solaris I can on win32 I can't
10-06-2004