javafx - How to block events to the underlying scene but not the window when a Dialog is open? -


basically, have application opens modal dialogs dont want user able continue working in main app while dialog open. however, modality.application_modal modality.window_modal both prevent minimizing , maximizing windows. problem when dialog gets triggered non-user event , user has minimized window -> cant open again.

now have sort of workaround opens dialog manually on main screen of user. make dialog non-modal if app minimized, work in application while ignoring dialog. both solutions not particularly pretty , not want.

i know "feature" there no way interact window not scene of owner stage? perhaps way block user events scene without using modality? seem pretty common use case me.

here minimalistic code example:

import javafx.application.application; import javafx.event.actionevent; import javafx.event.eventhandler; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.control.buttontype; import javafx.scene.control.dialog; import javafx.scene.control.scrollpane; import javafx.stage.modality; import javafx.stage.stage; import javafx.stage.stagestyle;  public class dialogdemo extends application {      @override     public void start(stage primarystage) {         stage mainstage = new stage();         button showdialogbtn = new button("show dialog");         showdialogbtn.setonaction(new eventhandler<actionevent>() {              @override             public void handle(actionevent event) {                 dialog<buttontype> dialog = new dialog<buttontype>();                 dialog.initstyle(stagestyle.decorated);                 dialog.initowner(mainstage);                 //prevents mainstage being resized, mini-/maximized , closed                 dialog.initmodality(modality.window_modal);                 dialog.getdialogpane().getbuttontypes().add(buttontype.close);                 dialog.show();             }         });         scrollpane pane = new scrollpane(showdialogbtn);         pane.setminsize(600, 480);         mainstage.setscene(new scene(pane));         mainstage.show();     }      public static void main(string[] args) {         launch(args);     } } 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -