PrefWidth/Height calculations only works if stage is shown

Scott Palmer swpalmer at gmail.com
Tue Sep 24 16:34:56 PDT 2013


On Wed, Aug 28, 2013 at 3:18 PM, John Smith <John_Smith at symantec.com> wrote:

> I hadn't seen the applyCSS conversation, but looks like it was contained
> deep in a node validation thread:
> http://mail.openjdk.java.net/pipermail/openjfx-dev/2013-July/008549.html
>
> Looks like the request is already covered in RT-21206 as pointed out by
> David.
> Looks like the feature will show up some time post-Java8, which is why
> there is nothing on Node now.
>
> For now, I stick with Kevin's node snapshot workaround:
>     // create a dummy scene so layout and CSS will work
>     new Scene(new Group(node));
>     node.shapshot(...)
>
> Thanks for the info!
>

I have a need to apply the CSS so when I 'snapshot' a node that isn't in my
scene, it looks correct.
I'm doing this:
Parent p = n.getParent(); // The node I want tosnapshot isn't the root of
the graph
Scene s = KayakFXUtils.createDarkScene(p,1000,1000);
n.impl_processCSS(true);
n.layout();

I get a reasonable size for the node, but the CSS isn't applied.

I get a ton of warnings like this:

WARNING: com.sun.javafx.css.StyleHelper calculateValue Could not resolve
'-fx-text-background-color' while resolving lookups for '-fx-text-fill'
from rule '*.label' in stylesheet
jar:file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_40/jre/lib/jfxrt.jar!/com/sun/javafx/scene/control/skin/caspian/caspian.bss

Ideas?


More information about the openjfx-dev mailing list