JDK-4036629 : Modal dialog does not prevent events on Solaris
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1,1.1.4
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 1997-03-05
  • Updated: 1998-09-16
  • Resolved: 1998-09-16
Related Reports
Duplicate :  
Description
It seems that MouseEvents and KeyEvents get delivered to Buttons, Labels & TextComponents in Windows other than the modal dialog. This happens on Solaris
but not on Windows 95. (I have tried 1.1_Final on both, 1.1.1 (as of 3/4) on Solaris.)

Here are two test cases. The first has a button which handles MOUSE_CLICKED.
You can continue to click and get more dialogs even after the first appears.

The second (Modal2) has a TextArea where pressing F1 brings up a modal dialog.
Again, on Solaris, you can continue pressing F1 and creating more.

I thought MODAL meant that no further events would be delivered?

------------ Modal.java ---------
import java.awt.*;
import java.awt.event.*;

public class Modal extends Label {

  public Modal(){
	enableEvents(-1);
	setBackground(Color.green);
  }

  public void processEvent(AWTEvent e){
    System.err.println("Modal:"+e);
    if(e instanceof MouseEvent){
	if(e.getID()==MouseEvent.MOUSE_CLICKED){
	   new MDialog((Frame)(getParent())).show();
	}
    }
  }

  public static void main(String[] args){
    Frame f = new Frame("Modal");
    f.add("Center",new Modal());
    f.setSize(200,200);
    f.show();
  }

}
  
class MDialog extends Dialog {
  MDialog(Frame f){
   super(f,"Dialog",true);
   enableEvents(-1);
   add("Center", new TextArea("Welcome to the modal. Quit the dialog to cancel."));
   pack();
  }

 public void processEvent(AWTEvent e){
   System.err.println("MDialog:"+e);
   if(e.getID()==WindowEvent.WINDOW_CLOSING){
	dispose();
   }
 }

}
------------ Modal2.java ---------
import java.awt.*;
import java.awt.event.*;

public class Modal2 extends TextArea {

  public Modal2(){
	enableEvents(-1);
  }

  public void processEvent(AWTEvent e){
    System.err.println("Modal2:"+e);
    if(e instanceof KeyEvent){
	if(e.getID()==KeyEvent.KEY_PRESSED){
	   if(((KeyEvent)e).getKeyCode()==KeyEvent.VK_F1){
	     new MDialog2((Frame)(getParent())).show();
	   }
	}
    }
  }

  public static void main(String[] args){
    Frame f = new Frame("Modal2");
    f.add("Center",new Modal2());
    f.pack();
    f.show();
  }

}
  
class MDialog2 extends Dialog {
  MDialog2(Frame f){
   super(f,"Dialog",true);
   enableEvents(-1);
   add("Center", new TextArea("You pressed F1. Quit the dialog to cancel."));
   pack();
  }

 public void processEvent(AWTEvent e){
   System.err.println("MDialog2:"+e);
   if(e.getID()==WindowEvent.WINDOW_CLOSING){
	dispose();
   }
 }

}

========================================
[Sheri Good 03/07/97]  Another report of this bug

From: Carsten Lindholst <###@###.###>

User: (internal)
Category: java
Subcategory: classes_awt
Bug/rfe/eou: bug
Synopsis: Modal Dialogs don't disable caption bar buttons in frames
Severity Impact: (internal)
Severity Functionality: (internal)
Priority: (internal)
Description: The window destroy button and other buttons on the caption bar
in frames are not disabled when modal dialogs are displayed.
This means that you can close down an application window (and in
most cases that means the app itself) when a modal dialog is
showing.

company - Digitron Development , email - ###@###.###
Work around: Hmmm.. in your WindowListener implementation you'd have to check
whether or not a modal dialog is shown, and then ignore any
action if that is the case.

Comments:
customer_rec: new
Company: other
Employee:Carsten Lindholst
Release: jdk11
Hardware Version: sun4u
O/S version: sol2.5.1
User Role: D
User Type: E
Sun Contact: (internal)
end_customer_rec: 
BUG_END

=============================================================
[another bug report from a user using 1.1.2.  Joon]
joon.oh@Eng 1997-08-25

/*

Compile and run the following code on both Windows and Solaris under JDK 1.1.2.

You will see a frame and 2 non-modal dialogs initially. You can press the buttons
in the non-modal dialogs and see a response line on the console. When the button
in the frame is pressed, a new modal dialog is created which is a child of the
frame (as are the non-modal ones).

When run under Windows, the program works as expected. Once the modal dialog is
shown, no input can be made to the frame or to the non-modal dialogs.

However, when run under Solaris, the program fails to work as expected. Most
importantly, the non-modal dialogs remain active and operable even after the
modal dialog has been shown. Less importantly, note that the location of the
dialogs as explicitly set by the program is not correct (this is also true of
the Frame).

*/

import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.*;

public class jdk112SolarisDialogBugs extends Frame
                                     implements ActionListener
{
   Button button = null;
   MyDialog dialog1 = null;
   MyDialog dialog2 = null;

   public jdk112SolarisDialogBugs()
   {
      super("Solaris Modal Dialog Bug");
      button = new Button("Press For Modal Dialog");
      button.addActionListener(this);
      add(button, "Center");
      setLocation(new Point(0, 0));
      doLayout();
      pack();
      show();

      dialog1 = new MyDialog(this, "NonModal 1", false);
      dialog1.button.setLabel("Can Press Now");
      dialog1.setLocation(new Point(300, 0));
      dialog1.doLayout();
      dialog1.pack();
      dialog1.show();

      dialog2 = new MyDialog(this, "NonModal 2", false);
      dialog2.button.setLabel("Can Press Now");
      dialog2.setLocation(new Point(300, 200));
      dialog2.doLayout();
      dialog2.pack();
      dialog2.show();
   }

   public void actionPerformed(ActionEvent e)
   {
      MyDialog dialog3 = new MyDialog(this, "Modal 1", true);
      dialog3.button.setLabel("Can Press Now");
      dialog1.button.setLabel("Cannot Press Now");
      dialog2.button.setLabel("Cannot Press Now");
      dialog3.setLocation(new Point(300, 400));
      dialog3.doLayout();
      dialog3.pack();
      dialog3.show();
   }

   public Dimension getPreferredSize()
   {
      return(new Dimension(300, 400));
   }

   public static void main(String[] argv)
   {
      new jdk112SolarisDialogBugs();
   }
}

class MyDialog extends Dialog
               implements ActionListener
{
   public Button button = null;

   public MyDialog(Frame frame, String title, boolean IsModal)
   {
      super(frame, title, IsModal);
      button = new Button("");
      button.addActionListener(this);
      add(button, "Center");
   }

   public void actionPerformed(ActionEvent e)
   {
      System.out.println("Dialog button pressed on Dialog: " + ((Dialog) ((Button) e.getSource()).getParent()).getTitle());
   }

   public Dimension getPreferredSize()
   {
      return(new Dimension(100, 200));
   }
}


company - HMS Software , email - ###@###.###

=============================================================
Another bug report from a user using 1.1.4.  Cuong Nguyen
cnguyen@scooter 1997/11/27 


When running in the Motif Window Manager, mwm, and
bringing up a Dialog designated as modal, then
the dialog is not modal.  The rest of the 
underlying application is still active. 

compary - VERITAS Software , email ###@###.###









Comments
EVALUATION duplicate of 4124096 xianfa.deng@Eng 1998-09-16
16-09-1998