I have a button which shows a choicelist as the content of a PopupView
when it is pressed.
The content of the PopupView
calculates its maxWidth based on the scene of the button.
Now I have noticed that switching Views
results in a layout pass of thePopupView
, although it's not showing. Since the scene is null at that time I get a NPE. This behaviour seems to be different from the Java PopupControl
, so I wonder if this is intended?
EDIT
It seems the layout pass is triggered by an update of the ListView
in the PopupView
. When I switch the View
I clear the items of the choicelist and the layout gets refreshed.
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.energymeter.control.skin.ChoiceMenuSkin.computeMaxWidth(ChoiceMenuSkin.java:120)
at javafx.scene.control.Control.computeMaxWidth(Control.java:506)
at javafx.scene.layout.Region.maxWidth(Region.java:1451)
at javafx.scene.layout.Region.computeChildPrefAreaWidth(Region.java:1728)
at javafx.scene.layout.BorderPane.getAreaWidth(BorderPane.java:610)
at javafx.scene.layout.BorderPane.computePrefWidth(BorderPane.java:445)
at javafx.scene.Parent.prefWidth(Parent.java:915)
at javafx.scene.layout.Region.prefWidth(Region.java:1419)
at com.sun.javafx.scene.control.skin.ScrollPaneSkin.computeScrollNodeSize(ScrollPaneSkin.java:929)
at com.sun.javafx.scene.control.skin.ScrollPaneSkin.layoutChildren(ScrollPaneSkin.java:822)
at javafx.scene.control.Control.layoutChildren(Control.java:576)
at javafx.scene.Parent.layout(Parent.java:1087)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Parent.layout(Parent.java:1093)
at javafx.scene.Scene.doLayoutPass(Scene.java:552)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2397)
at com.sun.javafx.tk.Toolkit.lambda$runPulse$30(Toolkit.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:354)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:381)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:510)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$404(QuantumToolkit.java:319)
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.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)