The question is about validation (kotlin ui dsl 2)
If I do it in standard way, it works:
override fun createCenterPanel() = panel {
if (name != null) {
row {
label("Schema name:")
textField().validationOnApply {
if (it.text.trim().isEmpty()) {
error("Name is required")
} else null
}.bindText({ name ?: "" }, { name = it })
.also {
focusedComponent = it.component
}
}.bottomGap(BottomGap.SMALL)
}
row {
cell(editSchemaComponent.getComponent())
}
}
}
But if I wrapped it using JBScrollPane, it doesn’t work
override fun createCenterPanel(): JComponent{
p = panel {
if (name != null) {
row {
label("Schema name:")
textField().validationOnApply {
if (it.text.trim().isEmpty()) {
error("Name is required")
} else null
}.bindText({ name ?: "" }, { name = it })
.also {
focusedComponent = it.component
}
}.bottomGap(BottomGap.SMALL)
}
row {
cell(editSchemaComponent.getComponent())
}
}
return JBScrollPane(p).apply {
preferredSize = Dimension(1000, 1000)
}
}
How to make it work? It’s very convenient to organize code with Kotlin UI DSL, sometimes I use cell(panel), etc. But have no idea how to make validation