指令集通用的 Kotlin 基础库,适用于 JVM/Swing 平台。
kotlin_version=1.9.24
java_version=8
dependencies {
implementation 'com.github.isyscore:common-swing:2.2.4.2'
}
api 'com.github.isyscore:common-jvm:2.2.4.2'
详细信息和用法参考本篇,此处不再赘述 点击进入
class MainForm: JFrame("Main") {
init {
contentPane = rootVertPanel {
val tbl = table(arrayRowData = arrayOf(arrayOf("A", true), arrayOf("B", false)), arrayColumnNames = arrayOf("Name", "Checked")) {
cell<JCheckBox> { cell, value, selected, cellHasFocus, row, col ->
// 此处的 this 是 JCheckBox
this.isSelected = value as Boolean
addActionListener { cell.setEditValue(this.isSelected, row, col) }
}
}
borderPanel {
button("Check") {
addActionListener {
val d1 = tbl.model.getValueAt(0, 1)
val d2 = tbl.model.getValueAt(1, 1)
println("d1 = $d1, d2 = $d2")
}
}
}
}
size { 500 x 300 }
isVisible = true
}
}