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

[macOS] Extension combobox in FileChooser fills all dialog width

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Mac OSX High Sierra 10.13.6, Java JDK 1.8.0_181

      A DESCRIPTION OF THE PROBLEM :
      When creating a FileChooser in JavaFX and set extensions, a combobox appears at the bottom of the file chooser to choose the extension, but this combobox is somewhat different from the native one. While the native just fills the width it needs depending on the maximum width of the text in the combo options, the one in JavaFX just fills all the width from the dialog window.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      In OSX, create a FileChooser from JavaFX, set some extension filters and show the dialog.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The combobox should be centered and fill only the necessary width to hold the maximum string size it contains, just like the native ones.
      ACTUAL -
      The combobox fills unnecessarily all width from the dialog window, and removing the margins present in the native extension selector.

      ---------- BEGIN SOURCE ----------
      import java.io.File;

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.stage.FileChooser;
      import javafx.stage.Stage;

      public class Snippet extends Application {

        @Override
        public void start(Stage primaryStage) {
          Button btn = new Button();
          btn.setText("click me");
          btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                final FileChooser fileChooser = new FileChooser();
                fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("All Files", "*.jpeg", "*.pdf", "*.tiff"), new FileChooser.ExtensionFilter("JPEG (*.JPEG, *.jpeg)", "*.jpeg", "*.JPEG"), new FileChooser.ExtensionFilter("PDF (*.PDF, *.pdf)", "*.pdf", "*.PDF"), new FileChooser.ExtensionFilter("TIF (*.tif, *.tiff)", "*.tif", "*.tiff"));
                File f = fileChooser.showSaveDialog(null);
            }
          });

          Scene scene = new Scene(btn, 500, 400);
          primaryStage.setScene(scene);
          primaryStage.show();
        }

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

      FREQUENCY : always


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

              Created:
              Updated: