问题
Consider the following JavaFx code running on JDK8:
/*Imports*/
public class StageResizing extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage){
stage.setScene(new Scene(new BorderPane(new Text("Text here.")), 200, 200));
stage.widthProperty().addListener((ObservableValue<? extends Number> ov, Number t, Number t1) -> {
stage.setHeight(t1.doubleValue());
});
stage.heightProperty().addListener((ObservableValue<? extends Number> ov, Number t, Number t1) -> {
stage.setWidth(t1.doubleValue());
});
stage.show();
}
}
It is intended to resize the width whenever the height is resized and vice-versa. (I believe setting a observable value to its own value wont trigger a ChangeEvent, right? )
The funny business is the when I resize the window from the corners, botton or top, it works as expected. But resizing from the right side of the windows won't change nothing and the left size will move the window with the same size instead.
Is there any specific reason or error in the code for this to happen?
Appreciate the attention.
来源:https://stackoverflow.com/questions/27835898/javafx-stage-resizing-strange-behaviour