Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8325549

Maximized main window resized when opening a dialog in Manjaro Linux

    XMLWordPrintable

Details

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Manjaro Linux on a Lenovo Legion laptop. OpenJDK 21.

      A DESCRIPTION OF THE PROBLEM :
      I've tested many versions ranging from 11 up to the most recent 23-ea+3, all rendering the same problem. When I open a main window, maximize the window, and then open a dialog and set the modality to either WINDOW_MODAL or APPLICATION_MODAL (for modality NONE the main window remains maximized) - when I run showAndWait() for the dialog, the main window is automatically resized to the non-maximized size (although remaining in the maximized state).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a class that extends Application
      2. Create a class that extends Dialog
      3. Create some GUI in both application and dialog classes
      4. Maximize the main application window
      5. Create a dialog, set initOwner(mainApplication.stage), set initModality(WINDOW_MODAL|APPLICATION_MODAL), run showAndWait()
      6. The main application window is resized while remaining in the maximized state

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      When the dialog is opened and when I run showAndWait() the maximized window should remain maximized without resizing.
      ACTUAL -
      The main application window is resized to the size of the non-maximized window state size, while remaining in the maximized state.

      ---------- BEGIN SOURCE ----------
      package test.application;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.*;
      import javafx.scene.input.KeyCombination;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.HBox;
      import javafx.stage.Modality;
      import javafx.stage.Stage;

      public class TestApplication extends Application {

          public static void main(String[] args) {
              launch(args);
          }

          private static class TestDialog extends Dialog<ButtonType> {

              public TestDialog(Stage primaryStage) {
                  super();
                  initModality(Modality.WINDOW_MODAL);
                  initOwner(primaryStage);
                  setResizable(false);
                  DialogPane dialogPane = getDialogPane();
                  dialogPane.setContent(new HBox());
                  ButtonType okButton = new ButtonType("Ok", ButtonBar.ButtonData.OK_DONE);
                  ButtonType cancelButton = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);
                  dialogPane.getButtonTypes().addAll(okButton, cancelButton);
                  showAndWait().ifPresent(response -> {
                      if(response.getButtonData() == ButtonType.OK.getButtonData()) {
                          /* Do something */
                      }
                  });
              }
          }
          @Override
          public void start(Stage primaryStage) throws Exception {
              BorderPane mainLayout = new BorderPane();
              MenuItem itemOpenDialog = new MenuItem("Open Dialog...");
              itemOpenDialog.setAccelerator(KeyCombination.keyCombination("Ctrl-D"));
              itemOpenDialog.setOnAction(event -> new TestDialog(primaryStage));
              MenuItem itemExit = new MenuItem("Exit");
              Menu menuFile = new Menu("File");
              menuFile.getItems().addAll(
                      itemOpenDialog,
                      new SeparatorMenuItem(),
                      itemExit
              );
              MenuBar menuBar = new MenuBar();
              menuBar.getMenus().addAll(menuFile);
              mainLayout.setTop(menuBar);
              Scene scene = new Scene(mainLayout, 1024, 768);
              primaryStage.setMinWidth(800);
              primaryStage.setMinHeight(600);
              primaryStage.setTitle("Test Application");
              primaryStage.setScene(scene);
              primaryStage.show();
              primaryStage.setMaximized(true);
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Haven't found any workaround, it's an internal event that's triggered and resizes the main window. Debugging so far doesn't show where it happens.

      FREQUENCY : always


      Attachments

        1. Clipping_from_submitter.mp4
          4.22 MB
          Praveen Narayanaswamy
        2. TestApplication.java
          2 kB
          Praveen Narayanaswamy

        Issue Links

          Activity

            People

              Unassigned Unassigned
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: