JDK-4087730 : JCK test ModalDialogTest0001 does not suppress user input in other windows.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.4
  • Priority: P1
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 1997-10-21
  • Updated: 2008-09-22
  • Resolved: 1997-12-23
Related Reports
Duplicate :  
Description
allan.jacobs@Eng 1997-10-21

The JCK test api/java_awt/interactive/descriptions.html#ModalDialogTest0001
allows the user to change the color of the main window for the test, even
when a modal dialog has been popped up.  The JDK is out of compliance.

Comments
EVALUATION Verified that this is a problem on Solaris but not a problem on Windows. Lara will reassign to a Motif engineer. creigton.chong@eng 1997-10-23 Standalone test program extracted from the JCK test: /* ModalDialogTests.java * author Gauri Sharma * Modal Dialog tests */ import java.io.PrintStream; import java.awt.*; import java.applet.*; import java.awt.event.*; public class ModalDialogTests extends Frame { Applet testPanel = null; String id = null; // These interactive tests use the Done user interface /* Standalone interface */ public static void main( String[] argv ) { ModalDialogTests test = new ModalDialogTests(); test.init(); test.setVisible(true); } // test ModalDialogTest0001: Verify that a modal dialog blocks input to its parent frame public void init() { // Add test panel to frame testPanel = new ModalDialogDisplayer(); ((ModalDialogDisplayer)testPanel).setLocationOfDialog(750, 200); add(testPanel); pack(); } public Dimension getPreferredSize() { return new Dimension(460, 240); } } /* ModalDialogDisplayer.java * Modal Dialog displayer * This applet displays a modal dialog */ import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class ModalDialogDisplayer extends Applet implements ActionListener { static Frame theFrame = new Frame("Modal Dialog Displayer"); static Dialog modalDialog = null; Button showButton = new Button("Show Modal Dialog"); Button redButton = new Button("Set panel color to red"); Button blueButton = new Button("Set panel color to blue"); Button dismissButton = new Button("Dismiss"); Panel buttonPanel = new Panel(); Panel colorPanel = new Panel(); public ModalDialogDisplayer() { modalDialog = new Dialog(theFrame, "Modal Dialog", true); modalDialog.setLayout(new FlowLayout()); modalDialog.setSize(200, 200); modalDialog.setBackground(Color.green); dismissButton.setBackground(Color.yellow); modalDialog.add(dismissButton); setLayout(new BorderLayout()); showButton.setBackground(Color.yellow); buttonPanel.add(showButton); buttonPanel.add(redButton); buttonPanel.add(blueButton); colorPanel.setBackground(Color.yellow); add("North", buttonPanel); add("Center", colorPanel); showButton.addActionListener(this); redButton.addActionListener(this); blueButton.addActionListener(this); dismissButton.addActionListener(this); } // Make dialog visible public void actionPerformed(ActionEvent e) { if (e.getActionCommand() == "Show Modal Dialog") modalDialog.setVisible(true); else if (e.getActionCommand() == "Set panel color to red") colorPanel.setBackground(Color.red); else if (e.getActionCommand() == "Set panel color to blue") colorPanel.setBackground(Color.blue); else if (e.getActionCommand() == "Dismiss") modalDialog.dispose(); else {} } public void setLocationOfDialog(int x, int y) { modalDialog.setLocation(x, y); } // Remove dialog public void cleanUp() { if (modalDialog != null) modalDialog.dispose(); } public static void main(String s[]) { ModalDialogDisplayer displayer = new ModalDialogDisplayer(); theFrame.add("Center", displayer); theFrame.pack(); theFrame.setSize(500, 300); theFrame.show(); theFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { if (modalDialog != null) modalDialog.dispose(); theFrame.dispose(); System.exit(0); } public void windowClosed(WindowEvent e) { if (modalDialog != null) modalDialog.dispose(); theFrame.dispose(); } }); } public void start() {} public void stop() {} public void destroy() {} } creighton.chong@eng 1997-10-27 ============================================================================ The problem is in the JCK test. It needs to be updated for the API change in JDK1.2 described in the mail below. The "Modal" Dialog is *not* a child of the "Modal Dialog Modality Test" Frame. It is actually a child of the Frame surrounding the "Modal" dialog. /usr/local/java/JCK-114a/unzip-test/JCK-114a/tests/api/java_awt/interactive/ModalDialogDisplayer.java: modalDialog = new Dialog(theFrame, "Modal Dialog", true); theFrame is not the same frame as testFrame in /usr/local/java/JCK-114a/unzip-test/JCK-114a/src/share/java/javasoft/sqe/jck/lib/InteractiveTest.java: testFrame = new Frame(); whose title is set in /usr/local/java/JCK-114a/unzip-test/JCK-114a/tests/api/java_awt/interactive/ModalDialogTests.java setFrameTitle("Modal Dialog Modality Test"); In Motif, there are three available dialog modalities: (1) system modal - user is prevented from interacting with any other window on display. (2) full application modal - user can not interact with any other windows in application, but can interact with any windows of other applications on the display. (3) primary application modal - user can not interact with the dialog's parent window, but can interact with any other window, *INCLUDING* siblings and ancestors other than the parent. As a result of the fix to BugId 4029855, dialogs now use modality (3) primary application modal. The following code from awt_Dialog.c chooses modality (3) primary application modal: if (wdata->isModal) { XtSetArg(args[argc], XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL) Unfortunately, in JDK1.1.x, a Dialog cannot be a child of another Dialog. It must be a child of a frame. This is the interface. public Dialog(Frame parent, String title, boolean modal) Constructs an initially invisible Dialog with a title. A modal Dialog grabs all the input to the parent frame from the user. The API has been changed for JDK1.2 to allow parenting of Dialogs from Dialogs. See mail below. From aim@taller Mon Nov 10 18:58:08 1997 Return-Path: <aim@taller> Received: from Eng.Sun.COM by shorter.eng.sun.com (SMI-8.6/SMI-SVR4) id SAA18741; Mon, 10 Nov 1997 18:58:08 -0800 Received: from taller.eng.sun.com (taller.Eng.Sun.COM [129.144.125.34]) by Eng.Sun.COM (SMI-8.6/SMI-5.3) with SMTP id SAA12736 for <awt-core@engmail2>; Mon, 10 Nov 1997 18:58:05 -0800 Received: from slotown.eng.sun.com by taller.eng.sun.com (SMI-8.6/SMI-SVR4) id SAA10430; Mon, 10 Nov 1997 18:58:01 -0800 Received: by slotown.eng.sun.com (SMI-8.6/SMI-SVR4) id SAA27923; Mon, 10 Nov 1997 18:57:59 -0800 Date: Mon, 10 Nov 1997 18:57:59 -0800 From: aim@taller (Amy Fowler) Message-Id: <###@###.###> To: awt-core@taller Subject: Code Manager notification Precedence: bulk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Length: 1631 Status: RO X-Status: $$$$ X-UID: Event: putback-to Parent workspace: /usr/green/SCCS_DIRECTORIES/JDK-AWT-1.2 (oakum:/export/disk0/green1/SCCS_DIRECTORIES/JDK-AWT-1.2) Child workspace: /home/aim/jdk1.2 (taller:/export/home6/aim/jdk1.2) User: aim Comment: !! Implemented proposed API for being able to parent Windows from Windows/Dialogs and Dialogs from Dialogs. This new AWT API was approved via the CCC. I've even implemented an automated test for this functionality! (Mark R's test framework makes this a piece of cake, btw). Also implemented DefaultCloseOperation property for Swing's JFrame and JDialog. We opted NOT to implemented this in the AWT classes because of JDK compatibility issues. Now you no longer have to write those annoying little Window listeners just to get the windows to close (the default is to automatically close the window). A couple tabbedpane argument value checks. Files: update: src/share/classes/java/awt/Frame.java update: src/share/classes/java/awt/Window.java update: src/share/classes/java/awt/Dialog.java update: src/share/classes/com/sun/java/swing/JTabbedPane.java update: src/share/classes/com/sun/java/swing/JDialog.java update: src/share/classes/com/sun/java/swing/JFrame.java update: build/share/minclude/java_swing.jmk update: build/share/minclude/java_swing11.jmk create: src/share/classes/com/sun/java/swing/WindowConstants.java create: test/java/awt/Window/WindowOwner.java create: test/java/awt/Window/WindowOwner.html create: test/java/awt/swing/Windows/DefaultCloseOperation.java create: test/java/awt/swing/Windows/DefaultCloseOperation.html mike.bronson@eng 1997-12-02 ===========================================================================
02-12-1997