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

Clarify Stage.resizableProperty().bindBidirectional()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 8
    • javafx
    • Mac OS X 10.7.5; JavaFX 8 under JDK 1.8.0 ea b82.

      The JavaDocs for Stage.resizableProperty() state that the property cannot be bound and attempting to do so will throw a RuntimeException. While Stage.resizableProperty().bind(...) indeed throws a RuntimeException, Stage.resizableProperty().bindBidirectional(...) does not.

      If bindBidirectional(...) is safe, the documentation should be clarified to make this clear, as it provides a convenient workaround in many use cases. If it is not safe, which is what I suspect, then it should also throw an Exception.

      See forum thread: https://forums.oracle.com/forums/thread.jspa?threadID=2518419&tstart=0

      The example from that thread, reproduced here, runs in Lombard but it's not clear if this really should throw a RuntimeException:

      import javafx.application.Application;
      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.paint.Color;
      import javafx.stage.Stage;
       
      public class BiDiBug extends Application {
        
        CheckBox checkBoxResizable;
       
        public static void main(String[] args) {
          Application.launch(args);
        }
        
        @Override
        public void start(final Stage stage) {
        
        stage.setResizable(true);
          
          Scene scene = SceneBuilder.create()
            .width(200)
            .height(100)
            .fill(Color.TRANSPARENT)
            .root(
              GroupBuilder.create()
                   .children(
                      checkBoxResizable = CheckBoxBuilder.create()
                        .selected(stage.isResizable())
                        .text("Is Stage resizable")
                        .build()
                      
                    )
                    .build()
                )
             .build();
          
          checkBoxResizable.selectedProperty()
                  .bindBidirectional(stage.resizableProperty());

          stage.setScene(scene);
          stage.show();
        }
      }

            msladecek Martin Sládeček
            jdenvirjfx James Denvir (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: