get size after CSS
Phil Race
philip.race at oracle.com
Mon Dec 24 10:58:19 PST 2012
I'm not the authority on CSS, far from it, but so far as I know that's
just how the CSS works. So the node has no idea of the pending change.
I recall Richard saying a couple of months ago that SceneBuilder
has the same issue/need. I don't know if a solution was applied there.
Perhaps you could listen in on the style string property on the node
and when you detect its changed parse it yourself, looking for font and
size and directly apply the new font/size to a dummy Text object and
extract the needed info from that ?
-phil.
On 12/22/2012 11:15 AM, Tom Eugelink wrote:
> I've got a javafx.scene.txt.Text node with a content that can be a
> longer multi line (because of the wrapping width) text. But the node
> serves as the title of a special type of appointment in the agenda
> control, and I want it to only show the text that fits on the first
> single line. For this I'm trying to use Text's clipping feature with a
> rectangle of height "M". My problem is that the font being used is set
> in CSS.
>
> How can I find out the Text's font height?
>
> I tried using a 'new Text("M")' and then use boundsInParent, but the
> CSS is applied after the next pulse, so the value of
> "getBoundsInParent().getHeight()" initially is that of the default
> font. I also tried listening to boundsInParentProperty and update the
> height when it gets invalidated, but that does not seem to be triggered.
>
> Tom
More information about the openjfx-dev
mailing list