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

ProgressBar uses fixed size (unlike all other JavaFX controls)

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 7u6
    • javafx

      As far as I know, most if not all JavaFX components voluntarily adhere to what ever size their parent layout pane assign to them. For example, a TextField in the center of a BorderPane, will not have a pref size or max size, allowing the border pane to stretch it, as the border pane sees fit.

      However, unlike all other components, a ProgressBar always sets a fixed pref width and max width of 100 pixels effectively crippling the layout policies of all the built in panes - no matter which layout pane you put a ProgressBar in, it will never stretch, thus forcing application developers write additional code to stretch it. You can even see this in the Ensemble demo, where progress bars are exactly 100 pixels, so the developer has manually set additional pref widths to vary the width.

      It is easy to work around this problem by adding this line of code everywhere you use a progress bar:
        progressBar.setPrefWidth(Double.MAX_VALUE);
      But I think it is strange and counter intuitive that you would need this additional line all over your app - we do not need that for buttons, text fields, text areas, and what not.

      A common use for a progress bar is to show a task progress dialog, such as the ones we see when software is installing. In all the dialogs I can remember, the progress bar spans the full width of the window it is in. Currently, you cannot do that without setting an explicit pixel precise prefWidth or using the work-around I have just showed.

            Unassigned Unassigned
            risaksen Randahl Isaksen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported: