Kotlin UI DSL expand component to fill height Follow
Hi,
I have created a dialog based on DialogWrapper (code below), but I can't find how to make the table expand as the dialog is resized:
class EditEnvVarSecretDialog(secret : EnvVarSecret) : DialogWrapper(true) {
private val myPanel = itemPanel(secret)
init {
title = "Edit Secret"
super.init()
}
override fun createCenterPanel(): JComponent? = myPanel
private fun itemPanel(secret : EnvVarSecret) = panel {
row("Secret path:") {
textField(secret::path)
}
row {
component(varsTable(secret)).growPolicy(GrowPolicy.MEDIUM_TEXT).constraints(CCFlags.grow)
}
}
private fun varsTable(secret : EnvVarSecret) : JComponent {
val tableModel = EnvVarTableModel(secret)
val table = JBTable(tableModel)
table.minimumSize = Dimension(200, 100)
val decorator = ToolbarDecorator.createDecorator(table)
decorator.setAddAction {
secret.envVarMapping.add(EnvVarSecretMapping())
tableModel.fireTableDataChanged()
}
decorator.setRemoveAction {
secret.envVarMapping.removeAt(table.selectedRow)
tableModel.fireTableDataChanged()
}
return decorator.createPanel()
}
}
The dialog looks like this:
I'd like the table to expand to fill the entire area marked red in the screenshot.
I have tried various CCFlags combinations, but nothing worked so far to make it expand to full height. How can I make the component auto expand?
Please sign in to leave a comment.