Search code examples
javafxtextflow

how to center an image in javafx


How can I move the facebook picture so that it is vertically centered to the text??

Code:

GridPane footerPane = new GridPane();     
double size = 15;

TextFlow textFlow = new TextFlow();
Text text1 = new Text("Get prayer time notifications and daily hadith on your mobile by following us on Facebook or Twitter");
text1.setFont(Font.font("Tahoma", size));
text1.setFill(Color.GRAY);
ImageView facebook = new ImageView(new Image(getClass().getResourceAsStream("/Images/facebook.png")));
Text text5 = new Text(".");
text5.setFont(Font.font("Tahoma", size));

textFlow.getChildren().addAll(text1, facebook, text5);
footerPane.setConstraints(footer_Label, 0, 0);
footerPane.getChildren().add(textFlow);

Image:

enter image description here


Solution

  • I have the same issue with TextFlow. I think TextFlow currently doesn't support a aligment for its children.