Getting the max and min out of heightProperty() and widthProperty()

Viewed 294

Is there any code, like Math.max(num1, num2) but for comparing two DoubleProperty s ? I am currently trying to displaying a circle (that extends from Pane) that can automatically resize itself according to the size of the window. I would like to try getting the smaller value between the two for setting the radius of the circle.

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class DisplayCircle extends Application {
   @Override
   public void start(Stage primaryStage) {
      Scene scene = new Scene(ResizableCircle(), 400, 300);
      primaryStage.setTitle("DisplayCircle");
      primaryStage.setScene(scene);
      primaryStage.show();
   }

   public class ResizableCircle extends Pane {
      public ResizableCircle() {
         Circle c = new Circle(getWidth()/2, getHeight()/2);
         c.centerXProperty().bind(widthProperty().subtract(10));
         c.centerYProperty().bind(heightProperty().subtract(10));


         // Need help setting the radius and binding it


         getChildren().add(c);
   }
}
1 Answers
Related