Stanislav
Stanislav

Reputation: 425

JavaFX request layout does nothing

I'm absolutely confused. Studying JavaFX for several months. In my application I have a custom scrollpane, where I recount scrollbar values manually. Everything is OK there. And when I resize the window it also works fine. The problem appears when I launch application the first time. I see that my scrollbar value is incorrect, and it become correct when I resize window or move the pane placed inside scrollpane. So theoretically all i need is just update my scrollpane on window start, or after window start. And... I've spent more than week trying to find out how. And the only way I've managed to do this is to call layoutChildren recursively. This is awful of course.

layout() - doesn't have any effect. I tried it with runLater() and placed it inside timer call. No way! requestLayout() - also makes no sense.

Is it possible just UPDATE or REDRAW or MARK CONTROL TREE AS DIRTY in JAVAFX ???

Upvotes: 1

Views: 3067

Answers (2)

subash
subash

Reputation: 3115

Ok well, try this way

first gaining the focus, then try relayout options..

blah.requestFocus();
blah.layout();

Upvotes: 2

Stanislav
Stanislav

Reputation: 425

Well. layout() works. But it shouldn't be placed inside Platform.runLater().

In simple example everything is fine. Then I suggest I have something wrong with my controls.

Thanks.

Upvotes: 0

Related Questions