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

Inconsistent behavior of javafx.scene.control.Dialog in linux

XMLWordPrintable

    • generic
    • linux

      ADDITIONAL SYSTEM INFORMATION :
      Operating System: Ubuntu 22.04.5 LTS
      Kernel: Linux 6.8.0-60-generic
      Architecture: x86-64
      KDE Plasma Version: 5.24.7
      Graphics Platform: X11

      Apache Maven 3.9.8
      Java version: 24.0.1, vendor: Oracle Corporation


      A DESCRIPTION OF THE PROBLEM :
      Dialog (javafx.scene.control.Dialog) class isn't displayed correctly in linux in comparison to Windows.
      The dialog is started with showAndWait, which mean it should be modal and:
      - not have the minimize and maximize buttons
      - the main window should not be clickable or resizable


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Start the program (for example with `mvn clean compile javafx:run`).
      2. Click "Hello!" button to open the dialog.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Dialog has only close button in the title bar.
      Main window can't be moved, minimized or closed.

      ACTUAL -
      Dialog has minimize and close buttons in the title bar. The minimize button does nothing.
      Main window can be minimized and moved.


      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.fxml.FXMLLoader;
      import javafx.scene.Scene;
      import javafx.stage.Stage;

      import java.io.IOException;

      public class HelloApplication extends Application {
          @Override
          public void start(Stage stage) throws IOException {
              FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
              Scene scene = new Scene(fxmlLoader.load(), 320, 240);
              stage.setTitle("Hello!");
              stage.setScene(scene);
              stage.show();
          }

          public static void main(String[] args) {
              launch();
          }
      }
      ---
      import javafx.fxml.FXML;
      import javafx.scene.control.Label;

      public class HelloController {
          @FXML
          private Label welcomeText;
          
          private ModalDialog dialog = new ModalDialog();

          @FXML
          protected void onHelloButtonClick() {
              welcomeText.setText(String.valueOf(dialog.showAndWait()));
          }
      }

      ---
      import javafx.scene.control.ButtonType;
      import javafx.scene.control.Dialog;
      import javafx.scene.control.Label;

      public class ModalDialog extends Dialog<Boolean> {
          
          public ModalDialog() {
              setTitle("Some");
              getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
              getDialogPane().setContent(new Label("Yes?"));
              setResultConverter(buttonType -> buttonType.equals(ButtonType.OK));
          }
      }

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

            angorya Andy Goryachev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: