Java Code Examples for java.awt.Dialog#isShowing()

The following examples show how to use java.awt.Dialog#isShowing() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlutterGuiTestRule.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private List<AssertionError> checkForModalDialogs() {
  List<AssertionError> errors = new ArrayList<>();
  // We close all modal dialogs left over, because they block the AWT thread and could trigger a deadlock in the next test.
  Dialog modalDialog;
  while ((modalDialog = getActiveModalDialog()) != null) {
    errors.add(new AssertionError(
      String.format(
        "Modal dialog %s: %s with title '%s'",
        modalDialog.isShowing() ? "showing" : "not showing",
        modalDialog.getClass().getName(),
        modalDialog.getTitle())));
    if (!modalDialog.isShowing()) break; // this assumes when the active dialog is not showing, none are showing
    robot().close(modalDialog);
  }
  return errors;
}
 
Example 2
Source File: TreeTableView152857Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void makeVisible(Dialog d) throws InterruptedException {
    d.setVisible(true);
    while (!d.isShowing()) {
        LOG.log(Level.INFO, "Waiting for is showing: {0}", d);
        Thread.sleep (1000);
    }
}
 
Example 3
Source File: CatalogAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override void actionPerformed(ActionEvent e) {
    
    Dialog dialog = dialogWRef.get ();

    if (dialog == null || ! dialog.isShowing ()) {

        final CatalogPanel cp = new CatalogPanel ();
        JButton closeButton = new JButton ();
        Mnemonics.setLocalizedText (closeButton,NbBundle.getMessage (CatalogAction.class, "BTN_CatalogPanel_CloseButton")); // NOI18N
        JButton openInEditor = new JButton ();
        openInEditor.setEnabled (false);
        OpenInEditorListener l = new OpenInEditorListener (cp, openInEditor);
        openInEditor.addActionListener (l);
        cp.getExplorerManager ().addPropertyChangeListener (l);
        Mnemonics.setLocalizedText (openInEditor,NbBundle.getMessage (CatalogAction.class, "BTN_CatalogPanel_OpenInEditorButton")); // NOI18N
        DialogDescriptor dd = new DialogDescriptor (cp,NbBundle.getMessage (CatalogAction.class, "LBL_CatalogPanel_Title"),  // NOI18N
                                false, // modal
                                new Object [] { openInEditor, closeButton },
                                closeButton,
                                DialogDescriptor.DEFAULT_ALIGN,
                                null,
                                null);
        dd.setClosingOptions (null);
        // set helpctx to null again, DialogDescriptor replaces null with HelpCtx.DEFAULT_HELP
        dd.setHelpCtx (null);
        
        dialog = DialogDisplayer.getDefault ().createDialog (dd);
        dialog.setVisible (true);
        dialogWRef = new WeakReference<Dialog> (dialog);
        
    } else {
        dialog.toFront ();
    }
    
}
 
Example 4
Source File: UIUtilities.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/** @return Whether or not the application is currently in a modal state. */
public static boolean inModalState() {
    for (Window window : Window.getWindows()) {
        if (window instanceof Dialog) {
            Dialog dialog = (Dialog) window;
            if (dialog.isShowing()) {
                ModalityType type = dialog.getModalityType();
                if (type == ModalityType.APPLICATION_MODAL || type == ModalityType.TOOLKIT_MODAL) {
                    return true;
                }
            }
        }
    }
    return false;
}