-
Bug
-
Resolution: Not an Issue
-
P4
-
fx2.1
-
Windows 7 32-bit, JavaFX 2.1
See code below.
I'm putting a VBox on the right side of a BorderPane. In JavaFX 2.0, this VBox would be sized as small as possible (both width and height), however, in JavaFX 2.1, two potential issues are causing the VBox to be maxed in both the width and height.
First, the Preferred Height of the VBox apparently is ignored, despite the docs for BorderPane saying that it will use the preferred height. This results in the VBox taking up max height, while in 2.0 it was taking up only a fraction of that.
Secondly, when giving any of the labels inside the VBox "setWrapText(true)", the entire VBox becomes maximized in the horizontal direction. I would prefer it would use the setMaxWidth of the label with setWrapText(true) and then wrap lines accordingly.
The test code below:
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class BorderPaneTest extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) throws Exception {
BorderPane borderPane = new BorderPane();
Scene scene = new Scene(borderPane);
VBox vBox = new VBox() {{
setPrefHeight(500);
setStyle(" -fx-background-color: rgba(0,0,0,0.5); -fx-background-radius: 0 0 0 15; ");
getChildren().add(new StackPane() {{
getChildren().add(new VBox() {{
getChildren().add(new HBox() {{
setAlignment(Pos.CENTER_LEFT);
getChildren().add(new ProgressIndicator() {{
setProgress(0.5);
}});
getChildren().add(new Label() {{
setText("My Title");
}});
}});
getChildren().add(new Label() {{
setText("My Somewhat longer description");
// setWrapText(true);
setMaxWidth(400);
}});
}});
}});
}};
borderPane.setRight(vBox);
stage.setScene(scene);
stage.setFullScreen(true);
stage.show();
System.out.println(vBox.getPrefHeight());
}
}
I'm putting a VBox on the right side of a BorderPane. In JavaFX 2.0, this VBox would be sized as small as possible (both width and height), however, in JavaFX 2.1, two potential issues are causing the VBox to be maxed in both the width and height.
First, the Preferred Height of the VBox apparently is ignored, despite the docs for BorderPane saying that it will use the preferred height. This results in the VBox taking up max height, while in 2.0 it was taking up only a fraction of that.
Secondly, when giving any of the labels inside the VBox "setWrapText(true)", the entire VBox becomes maximized in the horizontal direction. I would prefer it would use the setMaxWidth of the label with setWrapText(true) and then wrap lines accordingly.
The test code below:
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class BorderPaneTest extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) throws Exception {
BorderPane borderPane = new BorderPane();
Scene scene = new Scene(borderPane);
VBox vBox = new VBox() {{
setPrefHeight(500);
setStyle(" -fx-background-color: rgba(0,0,0,0.5); -fx-background-radius: 0 0 0 15; ");
getChildren().add(new StackPane() {{
getChildren().add(new VBox() {{
getChildren().add(new HBox() {{
setAlignment(Pos.CENTER_LEFT);
getChildren().add(new ProgressIndicator() {{
setProgress(0.5);
}});
getChildren().add(new Label() {{
setText("My Title");
}});
}});
getChildren().add(new Label() {{
setText("My Somewhat longer description");
// setWrapText(true);
setMaxWidth(400);
}});
}});
}});
}};
borderPane.setRight(vBox);
stage.setScene(scene);
stage.setFullScreen(true);
stage.show();
System.out.println(vBox.getPrefHeight());
}
}
- relates to
-
JDK-8117979 BorderPane doesn't correctly use (HORIZONTAL) content bias of it's children
- Closed