Suzan Cioc
Suzan Cioc

Reputation: 30097

How to deal with JavaFX node sizes?

I am astonished, how primitively sizes of nodes are apparently controlled in JavaFX. We have two dumb methods resize() and resizeRelocate() and that's all.

Where are events, where are observable properties and all this progressive stuff? Forgotten? Welcome Windows 3.1 API?

Is my impression wrong? Please fix me.

How to bind on node bounds? How to resize one node and resize other synchronously? How to fit one node into another? How to make inner node to push size of outer one?

How to tie some action with node resize?

Upvotes: 0

Views: 293

Answers (2)

ajeh
ajeh

Reputation: 2784

In simple terms, it's .addListener(new ChangeListener<T>() you are after.

Upvotes: 1

jewelsea
jewelsea

Reputation: 159291

Checkout this demo for understanding JavaFX Layout Bounds. It's a program I wrote when I first started learning JavaFX 2 to find out the answers to precisely the kind of questions you ask. It was written against an early JavaFX 2 version and some of the code would be more elegant with Java 8.

View Amy Fowler's presentation on JavaFX 2 layout.

Writing a good answer to this question would take some time. Definitely, your impression is wrong IMO. If I have the time and no better answers have been created, I'll come back and edit this answer to address specific questions and correct misconceptions.

Upvotes: 3

Related Questions