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

Incorrect behavior of Stage.resizableProperty().set()

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7u9
    • Fix Version/s: 8
    • Component/s: javafx
    • Labels:
    • Environment:

      Java 1.7.0_09, Windows 7 64.

      Description

      While you can change resizing behavior of a stage using Stage.setResizable() you cannot do that using Stage.resizableProperty().set(). Probably related problem is that binding to resizableProperty has no effect.

      Here is a sample program that illustrates that is below. You can resize a window only when "resizable" check box is set, not when only "resizableProperty" is set:
      {code}
      import javafx.application.Application;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.scene.GroupBuilder;
      import javafx.scene.Scene;
      import javafx.scene.SceneBuilder;
      import javafx.scene.control.CheckBox;
      import javafx.scene.control.CheckBoxBuilder;
      import javafx.scene.layout.VBoxBuilder;

      /**
       * Test resizing behaviour of a stage using Stage.setResizable() and Stage.resizableProperty().set().
       */
      public final class ResizablePropertyBug extends Application {


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

          @Override
          public void start(final Stage stage) {
              final CheckBox checkBoxResizable = CheckBoxBuilder.create()
                      .text("resizable")
                      .build();
              final CheckBox checkBoxResizableProperty = CheckBoxBuilder.create()
                      .text("resizableProperty")
                      .build();
              final Scene scene = SceneBuilder.create()
                      .width(270)
                      .height(370)
                      .root(GroupBuilder.create()
                              .children(
                                      VBoxBuilder.create()
                                              .layoutX(30)
                                              .layoutY(20)
                                              .spacing(10)
                                              .children(
                                                      checkBoxResizable,
                                                      checkBoxResizableProperty
                                              )
                                              .build()
                              )
                              .build()
                      )
                      .build();

              stage.setResizable(checkBoxResizable.selectedProperty().getValue());
              stage.resizableProperty().set(checkBoxResizableProperty.selectedProperty().getValue());

      // checkBoxResizableProperty.selectedProperty().bindBidirectional(stage.resizableProperty());
              checkBoxResizable.selectedProperty().addListener(new ChangeListener<Boolean>() {
                  @Override
                  public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                      stage.setResizable(checkBoxResizable.selectedProperty().getValue());
                  }
              });
              checkBoxResizableProperty.selectedProperty().addListener(new ChangeListener<Boolean>() {
                  @Override
                  public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                      stage.resizableProperty().set(checkBoxResizableProperty.selectedProperty().getValue());
                  }
              });

              stage.setScene(scene);
              stage.setTitle("Stage resizableProperty test");
              stage.show();
          }
      }
      {code}

        Attachments

          Activity

            People

            • Assignee:
              msladecek Martin Sládeček
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: