Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Exception on AutoCompleteComboBoxSkin resize #530

Closed
laurelmay opened this issue Nov 9, 2017 · 3 comments
Closed

Exception on AutoCompleteComboBoxSkin resize #530

laurelmay opened this issue Nov 9, 2017 · 3 comments

Comments

@laurelmay
Copy link

I have code similar to the following:

form {
    fieldset("Set") {
        field("") {
            combobox(property) {
                promptText = "STRING"
                setCellFactory { genListCell() }
                buttonCell = genListCell()
                makeAutocompletable { /*...*/ }
            }
        }
    }
}

I get the stacktrace below when I use my arrow keys to scroll through the ComboBox options and I reach an item whose width is wider than the current width of the AutoCompleteComboBoxSkin.

Before I added the makeAutocompletable call, the ComboBox was always wide enough to hold the contained elements; however after adding that call, the ComboBox is only wide enough to fit the promptText.

The function header of genListCell is fun genListCell(): ListCell<Type>. I am have noticed this issue on version 1.7.9 and 1.7.12 (I have not tested any versions in between). I am using Kotlin 1.1.51 and am targeting JVM 1.8.

Stacktrace:

java.lang.RuntimeException: ListView.prefWidth : A bound value cannot be set.
	at javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:143)
	at javafx.css.StyleableDoubleProperty.set(StyleableDoubleProperty.java:82)
	at javafx.scene.layout.Region.setPrefWidth(Region.java:1076)
	at javafx.scene.layout.Region.setPrefSize(Region.java:1121)
	at com.sun.javafx.scene.control.skin.ComboBoxPopupControl.reconfigurePopup(ComboBoxPopupControl.java:322)
	at com.sun.javafx.scene.control.skin.ComboBoxPopupControl.lambda$createPopup$297(ComboBoxPopupControl.java:271)
	at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:349)
	at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
	at javafx.beans.property.ReadOnlyDoublePropertyBase.fireValueChangedEvent(ReadOnlyDoublePropertyBase.java:72)
	at javafx.beans.property.ReadOnlyDoubleWrapper.fireValueChangedEvent(ReadOnlyDoubleWrapper.java:103)
	at javafx.beans.property.DoublePropertyBase.markInvalid(DoublePropertyBase.java:113)
	at javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:147)
	at javafx.scene.layout.Region.setWidth(Region.java:858)
	at javafx.scene.layout.Region.resize(Region.java:1364)
	at javafx.scene.layout.Region.layoutInArea(Region.java:2325)
	at javafx.scene.layout.Region.layoutInArea(Region.java:2238)
	at javafx.scene.layout.HBox.layoutChildren(HBox.java:643)
	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.Parent.layout(Parent.java:1093)
	at javafx.scene.Parent.layout(Parent.java:1093)
	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)
@laurelmay laurelmay changed the title Exception on AutoCompleteComboBoxSkin Exception on AutoCompleteComboBoxSkin resize Nov 10, 2017
edvin pushed a commit that referenced this issue Nov 10, 2017
@edvin
Copy link
Owner

edvin commented Nov 10, 2017

It seems you're binding the listView.prefWidthProperty, and the auto complete skin tries to set it. I've committed a fix that inspects the property to see if it's bound before attempting to set it.

You can also try passing automaticPopupWidth = true to see if that fits your use case better. Does this help?

@laurelmay
Copy link
Author

So it after looking into it, it looks like even though I updated my build.gradle file to use 1.7.12, it was still using 1.7.9 when building. This issue is resolved in 1.7.12. It looks like the issue may have been in AutoCompleteComboBoxSkin.kt:224 in 1.7.9 where it was binding against ListView.prefWidthProperty. I apologize for the incorrect information in the initial report, but I do appreciate the fix that was implemented. Hopefully it prevents any future issues.

@edvin
Copy link
Owner

edvin commented Nov 10, 2017

Thanks for explaining. This was a nice improvement to get in there anyways, so I'm happy you reported it :)

@edvin edvin closed this as completed Nov 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants