I am trying to create a Container
(in this case an HBox, but could be a StackPane, VBox, or otherwise); which contains a Group, and attached to the group is a MediaView.
If I simply create the objects without setting any margins etc., there appears a strange 9px gap between the start of the HBox (background blue below) and start of the Group (with MediaView attached coloured green below)
If I explicitly use root.setTranslateX(-9);
the HBox is moved over 9 pixels and the problem appears to be alleviated because it's been offset. This is, however, the only way I have found to solve this problem! Even if I use .setMargins(...);
it still does this.
Any ideas as to why this happens?
I attempted this again (code below). Interestingly it seems as though the gap is on the right.
public class HelloWorld extends Application {
HBox root = new HBox();
MediaView view = new MediaView();
public HelloWorld(){
}
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World!");
Group rootGroup = new Group();
root.getChildren().add(rootGroup);
root.setAlignment(Pos.CENTER_LEFT);
root.setTranslateX(-9);
root.setStyle("-fx-background-color: #039ED3;");
rootGroup.getChildren().add(view);
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
}
}