ADDITIONAL SYSTEM INFORMATION : MacOS 14.5 on Apple M1 (MacBook Air M1, 2020), Java 17.0.11 A DESCRIPTION OF THE PROBLEM : Calling BorderPane.setPadding(new Insets(16)) and then adding a TextFlow as central component gives a different result than adding the padding the the TextFlow instead. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run the provided test file EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - What I'm expected is what displayed invoking testPaddingFlow (where the 16 pixels padding was added to the text flow instead of the border pane). Moreover changing slightly the text in the flow the result is different. ACTUAL - Invoking testPaddingContainer I'm expected to see 16 pixels of empty space around the central TextFlow component, but this is not the case. ---------- BEGIN SOURCE ---------- package jdk.irXXX; import java.util.concurrent.TimeUnit; import org.junit.Test; import org.testfx.api.FxRobot; import org.testfx.framework.junit.ApplicationTest; import org.testfx.util.WaitForAsyncUtils; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.scene.layout.Region; import javafx.scene.layout.StackPane; import javafx.scene.text.Text; import javafx.scene.text.TextFlow; import javafx.stage.Stage; public class TextFlowPaddingText extends ApplicationTest { private StackPane rootPane; @Override public void start(Stage stage) { rootPane = new StackPane(); rootPane.setId("rootPane"); rootPane.setPadding(new Insets(40)); rootPane.getStyleClass().add("root"); Scene scene = new Scene(rootPane); stage.setTitle("TestFlow Padding Test"); stage.setScene(scene); stage.setWidth(700); stage.setHeight(400); stage.show(); stage.toFront(); stage.centerOnScreen(); } @Test public void testPaddingContainer() { System.out.println("Testing padding on container..."); TextFlow flowEN = new TextFlow( new Text("We have made changes to RI keyboard shortcuts to ensure they " + "are easier to discover, memorize and don't conflict with " + "those of other programs, actions within RI, or potential " + "new shortcuts added in the future.\n\n" + "If you are used to old shortcuts, we suggest reviewing " + "the new list, which can be found under " + "\"Help -> Keyboard shortcuts\".")); flowEN.setStyle("-fx-border-color: red; -fx-border-width: 1px;"); BorderPane containerEN = new BorderPane(flowEN); containerEN.setPadding(new Insets(16)); initContainer(containerEN); FxRobot robot = new FxRobot(); robot.interact(() -> { StackPane.setAlignment(containerEN, Pos.CENTER_LEFT); rootPane.getChildren().add(containerEN); }); TextFlow flowES = new TextFlow( new Text("Hemos efectuado cambios en los atajos de teclado de RI para garantizar " + "que son más sencillos de descubrir y memorizar, y que no entren en " + "conflicto con los de otros programas, acciones dentro de RI o nuevos " + "atajos potenciales que se añadan en el futuro.\n\n" + "Si se ha acostumbrado a los anteriores atajos, le sugerimos que revise " + "la nueva lista, la cual podrá encontrar en \"Ayuda -> Atajos de teclado\".")); flowES.setStyle("-fx-border-color: red; -fx-border-width: 1px;"); BorderPane containerES = new BorderPane(flowES); containerES.setPadding(new Insets(16)); initContainer(containerES); robot.interact(() -> { StackPane.setAlignment(containerES, Pos.CENTER_RIGHT); rootPane.getChildren().add(containerES); }); WaitForAsyncUtils.sleep(17777L, TimeUnit.MILLISECONDS); } @Test public void testPaddingFlow() { System.out.println("Testing padding on TetxtFlow..."); TextFlow flowEN = new TextFlow( new Text("We have made changes to RI keyboard shortcuts to ensure they " + "are easier to discover, memorize and don't conflict with " + "those of other programs, actions within RI, or potential " + "new shortcuts added in the future.\n\n" + "If you are used to old shortcuts, we suggest reviewing " + "the new list, which can be found under " + "\"Help -> Keyboard shortcuts\".")); flowEN.setStyle("-fx-border-color: red; -fx-border-width: 1px;"); flowEN.setPadding(new Insets(16)); BorderPane containerEN = new BorderPane(flowEN); initContainer(containerEN); FxRobot robot = new FxRobot(); robot.interact(() -> { StackPane.setAlignment(containerEN, Pos.CENTER_LEFT); rootPane.getChildren().add(containerEN); }); TextFlow flowES = new TextFlow( new Text("Hemos efectuado cambios en los atajos de teclado de RI para garantizar " + "que son más sencillos de descubrir y memorizar, y que no entren en " + "conflicto con los de otros programas, acciones dentro de RI o nuevos " + "atajos potenciales que se añadan en el futuro.\n\n" + "Si se ha acostumbrado a los anteriores atajos, le sugerimos que revise " + "la nueva lista, la cual podrá encontrar en \"Ayuda -> Atajos de teclado\".")); flowES.setStyle("-fx-border-color: red; -fx-border-width: 1px;"); flowES.setPadding(new Insets(16)); BorderPane containerES = new BorderPane(flowES); initContainer(containerES); robot.interact(() -> { StackPane.setAlignment(containerES, Pos.CENTER_RIGHT); rootPane.getChildren().add(containerES); }); WaitForAsyncUtils.sleep(17777L, TimeUnit.MILLISECONDS); } private void initContainer(BorderPane container) { container.setMinWidth(16 + 80 + 16); container.setMaxWidth(16 + 240 + 16); container.setPrefHeight(Region.USE_COMPUTED_SIZE); container.setMaxHeight(Region.USE_PREF_SIZE); container.setStyle("-fx-border-color: black; -fx-border-width: 1px;"); } } ---------- END SOURCE ---------- FREQUENCY : always
|