This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I would like to ensure that my main window always has the same height/width ratio. I was hoping there would be some sort of 'Resize' event, but I can't find one.
I can get separate callbacks on height changing and width changing - but trying to maintain proportions in two separate callbacks strikes me as being a lot more difficult (they can be making it larger or smaller, sometimes they change height, sometimes they change width, sometimes they change both at the same time).
Can anyone point me to a solution? Sorry if there is an obvious solution I'm just overlooking.
And the do the same for height.
Then bind the stageHeightProperty to a proportion of the stageWidthProperty, e.g.
I didn't try the exact code to get the exact result you are requesting, but by playing around using the tips provided you should be able to achieve the effect you need.
Joined: May 31, 2011
Unfortunately, I could not get that to work. Creating new simple double properties passing in the width in the constructor did not trigger the callback. When I used the actual stage properties it said they had to be read only properties. When I did a cast I got a cast exception.
I gave up on binding and just tried to change the size in the callback of the read only property ... it's funny, the callback kept getting the updated size but the size never changed on the screen.