layoutChildren without min/pref size?
Tom Eugelink
tbee at tbee.org
Wed Apr 2 19:23:14 UTC 2014
I stand corrected; it turned out I had a beta version of TestFX somewhere in my classpath. The latest 3.1.2 does not show this behavior.
On 2014-4-2 19:11, Tom Eugelink wrote:
> Hi Martin,
>
> To be clear; I check the sizes of all my children, the problem is in the fact that my layout's layoutChildren() is called without its compute* methods being called prior to that. Hence the calculations are not done and I get an NPE.
>
> I have printlns in the compute* and layoutChildren methods, and as you can see the compute* methods are not called. Even if I work around the NPE and resize the window, the compute* are never called.
>
> /layoutChildren() //
> //java.lang.NullPointerException//
> // at jfxtras.labs.scene.layout.CircularPane.layoutChildren(CircularPane.java:216)//
> // at javafx.scene.Parent.layout(Parent.java:1076)//
> // at javafx.scene.Scene.doLayoutPass(Scene.java:576)//
> // at javafx.scene.Scene.preferredSize(Scene.java:1579)//
> // at javafx.scene.Scene.impl_preferredSize(Scene.java:1653)//
> // at javafx.stage.Window$SceneModel.invalidated(Window.java:478)//
> // at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)//
> // at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:145)//
> // at javafx.stage.Window.setScene(Window.java:436)//
> // at javafx.stage.Stage.setScene(Stage.java:240)//
> // at org.loadui.testfx.GuiTest$1.run(GuiTest.java:128)//
> // at org.loadui.testfx.FXTestUtils$4.call(FXTestUtils.java:151)//
> // at org.loadui.testfx.FXTestUtils$4.call(FXTestUtils.java:147)//
> // at org.loadui.testfx.FXTestUtils$3.run(FXTestUtils.java:109)//
> // at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301)//
> // at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298)//
> // at java.security.AccessController.doPrivileged(Native Method)//
> // at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:298)//
> // at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)//
> // at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)//
> // at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)//
> // at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)//
> // at java.lang.Thread.run(Thread.java:744)//
> /
> Now, TestFX uses a deviating way of initializing the Stage and Scene, but in the end it simply does a setScene, which ends up in my layoutChildren without reaching out to compute*.
>
> Tom
>
>
>
> On 2014-4-2 18:42, Martin Sladecek wrote:
>> Hi Tom,
>> in all of our layout panes we do check for min/pref/max size (I think), but strictly speaking they are all just size hints so I can imagine a layout pane which would not check for these and compute the size of the child in some different way. On the other hand, the size hints, esp. min size gives an information about the minimum size of the Node with which is the Node "usable".
>>
>> But to be safe, you should always check for validity of your cached calculations in all compute* methods + at the beginning of layoutChildren().
>>
>> -Martin
>>
>> On 2.4.2014 16:34, Tom Eugelink wrote:
>>>
>>> I'm currently working on a circular pane and am in the phase of writing tests. For optimalisation the layout does some (cached) calculations in the computePrefWidth, because, after all, how can a node be laid out if its container does not know what its min and pref sizes are? This works perfectly for all the trials I've written, putting the pane directly into the scene, or part of other panes.
>>>
>>> But in the test (using TestFX) the layoutChildren() is called without ever calling computeMin/PrefWidth... Does that make sense?
>>>
>>> Tom
>>>
>>
>
More information about the openjfx-dev
mailing list