public void testInterceptingAJDialogShownFromAnotherThread() throws Exception {
   Window window =
       WindowInterceptor.getModalDialog(
           new Trigger() {
             public void run() throws Exception {
               thread =
                   new Thread() {
                     public void run() {
                       JDialog dialog = createModalDialog("expected title");
                       addHideButton(dialog, "OK");
                       dialog.setVisible(true);
                     }
                   };
               thread.start();
             }
           });
   window.titleEquals("expected title");
   window.getButton("OK").click();
   assertFalse(window.isVisible());
   window.dispose();
 }
 public void testInterceptingUsingAButtonTrigger() throws Exception {
   Button button = new Button(new JButton(new ShowDialogAction(true)));
   Window window = WindowInterceptor.getModalDialog(button.triggerClick());
   window.titleEquals("MyDialog");
   window.dispose();
 }