Duplicate :
|
Name: gvC48267 Date: 12/05/97 Oracle Licensee On Win32, a modal dialog grabs input from all the existing frames of the underlying application. On Solaris, a modal dialog grabs input only from the parent frame. The JDK spec is pretty vague on wording what modality means and how it should be implemented. Test case to reproduce the bug is attached. /* * ModalBug.java * Test case to reproduce inconsistent modality implementation bug. * Description * The AWT definition of setting "modal" flag to true in java.awt.Dialog * is as follows : * A modal Dialog grabs all the input to the parent frame from the user. * The JavaSoft's implementation on Win32 grabs input from all the frames * and not just the parent frame in the application. However, the * implementation on Solaris only grabs the input from the parent window. * One of the implementations needs to be changed for consistency. * How to reproduce : * - Compile ModalBug.java and run it * - you will see two windows, Parent and Frame1 * - click on "show dialog" button in Parent (Parent is dialog's parent) * - this will bring up a modal dialog called "Dialog" * - On Win32, you won't be able to access Parent and Frame1 frames. * On Solaris, you will be able to access Frame1. * Author Sridhar Reddy (###@###.###), 12/3/1997 */ import java.awt.Dialog; import java.awt.Frame; import java.awt.Button; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class ModalBug implements ActionListener { Frame parent; // parent frame Frame frame; // some frame Dialog dialog; // a modal dialog Button showDialog; // button to popup modal dialog Button printHello; // button to print hello to stdout // constructor - creates two frames and a modal dialog public ModalBug() { parent = new Frame("Parent"); showDialog = new Button("show dialog"); showDialog.addActionListener(this); parent.add(showDialog); parent.setSize(100, 100); parent.setLocation(1,1); dialog = new Dialog(parent, "Dialog", true); dialog.setSize(100, 100); dialog.setLocation(250, 150); frame = new Frame("Frame1"); printHello = new Button("print hello"); frame.add(printHello); printHello.addActionListener(this); frame.setSize(100, 100); frame.setLocation(120, 1); } // shows the frames public void show() { parent.setVisible(true); frame.setVisible(true); } // ActionListener implementation public void actionPerformed(ActionEvent event) { if (event.getSource() == showDialog) dialog.show(); else System.out.println("print hello"); } // test main public static void main(String[] args) { ModalBug bug = new ModalBug(); bug.show(); } } (Review ID: 21370) ======================================================================