Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : java version "1.8.0_51" Java(TM) SE Runtime Environment (build 1.8.0_51-b16) Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode) ADDITIONAL OS VERSION INFORMATION : Windows 64bit ver 7 A DESCRIPTION OF THE PROBLEM : When I run the following program import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import javafx.scene.shape.Ellipse; import javafx.stage.Stage; public class Test1 extends Application { public static void main(String[] args) throws Exception { launch(args); } @Override public void start(Stage stage) throws Exception { Pane topPane = new Pane(); Scene scene = new Scene(topPane, 600, 400); StackPane sp = new StackPane(); Label l1 = new Label("1 2"); Ellipse e1 = new Ellipse(100, 50); e1.setOpacity(0.5); sp.getChildren().addAll(l1, e1); e1.radiusXProperty().bind(l1.widthProperty()); e1.radiusYProperty().bind(l1.heightProperty()); topPane.getChildren().add(sp); sp.relocate(200, 100); sp.setStyle("-fx-border-color: RED;"); Platform.runLater(() -> { //l1.setText("123"); //l1.setText("1 2"); }); stage.setScene(scene); stage.show(); } } I get a red box surrounding the text label only, but when I uncomment the two lines inside the Platform.runLater() block above, I get a red box surrounding the outer ellipse, which is what I want. So it seems to me the layout bounds of the stack pane is not set correctly from the model description, since the bounds are determined only from the label control. But when I force an invalidation in Platform.runLater() the layout bounds are where they should be. Why is this happening and how do I prevent it? I would like to be able to just specify my model/graph and then it should render correctly on the first show, or? Also see stackexchange question http://stackoverflow.com/questions/32271672/javafx-stackpane-bounds-not-updated ADDITIONAL REGRESSION INFORMATION: java version "1.8.0_51" Java(TM) SE Runtime Environment (build 1.8.0_51-b16) Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode) STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run the program in the description and it will happen. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - I expect to see a a red box border surrounding the outer ellipse, as specified in the model. ACTUAL - I see a red box surrounding the label. But if I uncomment the 2 comment lines in the code, I get the expected behaviour. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import javafx.scene.shape.Ellipse; import javafx.stage.Stage; public class Test1 extends Application { public static void main(String[] args) throws Exception { launch(args); } @Override public void start(Stage stage) throws Exception { Pane topPane = new Pane(); Scene scene = new Scene(topPane, 600, 400); StackPane sp = new StackPane(); Label l1 = new Label("1 2"); Ellipse e1 = new Ellipse(100, 50); e1.setOpacity(0.5); sp.getChildren().addAll(l1, e1); e1.radiusXProperty().bind(l1.widthProperty()); e1.radiusYProperty().bind(l1.heightProperty()); topPane.getChildren().add(sp); sp.relocate(200, 100); sp.setStyle("-fx-border-color: RED;"); Platform.runLater(() -> { //l1.setText("123"); //l1.setText("1 2"); }); stage.setScene(scene); stage.show(); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Add sp.requestLayout(); after stage.Show();
|