I'm trying to add a "+" tab in a tabpane to create...
# tornadofx
k
I'm trying to add a "+" tab in a tabpane to create more tabs. Everything else is working fine, but calling
close()
from the tab itself throws a NPE. Minimal example:
Copy code
class addTab : View(" + ") {
    override val root = label("You should not see this.")

    override fun onTabSelected() {
        super.onTabSelected()
        with(MainView.tabs) {
            tab("new", nonuniqueTab("foo"))
            tabs[tabs.size - 1].select()
        }
        close()
    }
}
creates a new tab from fragment just fine, tabs is the tabpane, but close causes
java.lang.NullPointerException: Cannot invoke "javafx.beans.value.ChangeListener.changed(javafx.beans.value.ObservableValue, Object, Object)" because "<local3>[<local7>]" is null
Or is it possible to reorder or open a tab between existing tabs to avoid having to close and reopen the + tab?
Copy code
class addTab : View(" + ") {
    override val root = label("You should not see this.")

    override fun onTabSelected() {
        super.onTabSelected()
        with(MainView.tabs) {
            tab<nonuniqueTab> {label("new")}
            tabs[tabs.size - 1].select()
            tab<addTab> {}
            tabs.removeAt(tabs.size-3)
        }
    }
}
this no longer causes a NPE after the first time the tab is closed and reopened, but still does initially. I have no clue what is different about closing it for the first time vs subsequent calls.