1

This is question about javaFX8.
I have listView and custom cellFactory.
every cell is : good cell view it is:
1.AnchorPane
1.1.Circle
1.1.AnchorPane
1.1.1.Label
1.1.2.Label
1.1.3.TextFlow

But if text in TextFlow is large, I see this image bad cell view

So in updateItem menthod I do this

Text text = new Text();
text.textProperty().setValue(data.getMessage());
....
messageTextFlow.getChildren().addAll(text);
....
double height = (messageTextFlow.getChildren().get(0)).getLayoutBounds().getHeight() + 28;
anchorPane.setPrefHeight(height);

But it doesn't work the first time. The correct height of the cell exposed only once again I will update this listview.

How can I solve this problem? Is there are any method to connect TextFlow height with ListCell height?

Thank you!

otopba
  • 214
  • 1
  • 6
  • 14
  • 3
    Please add a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) to your question. This makes it easier for people to debug and offer a solution to your question. – ItachiUchiha May 05 '16 at 19:03
  • 2
    Don't use `AnchorPane`s when you want to manage the layout like this. There are [layout panes](http://docs.oracle.com/javase/8/javafx/layout-tutorial/builtin_layouts.htm#JFXLY102) which already manage the layout for you, e.g. put the two labels in an `HBox` and the `HBox` amd `TextFlow` in a `VBox`, then the `Circle` and `VBox` in another `HBox`. Set appropriate alignment etc on all the layout panes. (As suggested, you will need to create and post a [MCVE] if you want a more precise answer.) – James_D May 05 '16 at 19:26

1 Answers1

-1

I found answer on https://stackoverflow.com/a/26152904/1299231

What I need to do is just add this two lines:

parentNode.applyCss();
parentNode.layout()
Community
  • 1
  • 1
otopba
  • 214
  • 1
  • 6
  • 14