class DetailView : View() { val basicView: BasicViewPane by inject() val expandedWith = 250.0 val accordion = accordion { prefWidth = expandedWith fold("basic", basicView.root, expanded = true) fold("exif", VBox()) { label("test") label("test") label("test") label("test") } } override val root = vbox { isVisible = false } fun toggle() { if (root.isVisible) { root.isVisible = false accordion.removeFromParent() } else { root.add(accordion) root.isVisible = true } } }