JDK-8243149 : [macos] Alerts are shown as separate Tab in fullscreen mode
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 8,openjfx14
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2020-04-20
  • Updated: 2021-04-27
  • Resolved: 2021-04-27
Related Reports
Duplicate :  
Description
When entering fullscreen mode on MacOS, dialogs/alerts are not shown correctly. 
Instead a separate tab is opened where the content of the dialog is shown.

The following example program shows the problem:

package prv.rli.codetest;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class DialogConfirmDangerousAction extends Application {

    public DialogConfirmDangerousAction() {
    }

    @Override
    public void start(Stage stage) throws Exception {
        stage.setTitle("Dialog default button");
        Scene scene = new Scene(new VBox(), 400, 350);
 
        MenuBar menuBar = new MenuBar();
 
        // --- Menu File
        Menu menuFile = new Menu("File");
        menuBar.getMenus().addAll(menuFile);
        
        MenuItem test = new MenuItem("Open Dialog");
        test.setAccelerator(KeyCombination.keyCombination("Ctrl+O"));
        test.setOnAction(new EventHandler<ActionEvent>() {
            public void handle(ActionEvent t) {
        		Alert alert = new Alert(AlertType.CONFIRMATION);
        		alert.setTitle("Really");
        		alert.setHeaderText("Danger, Will Robinson");
        		alert.setContentText("This will make the universe collapse. Are you sure?");
        		ButtonType yes = new ButtonType("Yes", ButtonData.OTHER);
        		ButtonType no = new ButtonType("No", ButtonData.CANCEL_CLOSE);
        		alert.getButtonTypes().setAll(no, yes);
            	alert.showAndWait();            	
            }
        });                
        
        menuFile.getItems().add(test);
 
        ((VBox) scene.getRoot()).getChildren().addAll(menuBar);
 
        stage.setScene(scene);
        stage.show();    
    }
    
    public static void main(String[] args) {
        launch(args);
    }
}

If it is started, fullscreen mode is entered and the menu item activated, the dialog is shown as described above.
Comments
Btw, I think that having an unowned window open in another "screen" in full-screen mode is a reasonable behavior. "Owned" dialogs should open in the same screen on top of the parent window. If that isn't happening, then you can file a new bug.
27-04-2021

It was fixed in JavaFX 17 with JDK-8263169. While it might not be ideal in full-screen mode, it at least avoids the problem described in this bug report. Closing as a duplicate.
27-04-2021

I think this problem has been fixed in JavaFX 16. The dialog is opened on a separate "Screen" now, which is not exactly what I would have expected but certainly better than opening a second tab.
27-04-2021

I can reproduce this using JDK 14 and JavaFX 15-ea. It also reproduces on JDK 8u. The problem happens either if I enter full screen mode using the macOS "full-screen" button in the window decoration, or by modifying the program to call stage.setFullScreen(true) before showing the stage. This is not a regression, but is a usability issue. Raising the priority to P3.
21-04-2020