repositories {
mavenCentral()
}
dependencies {
implementation("io.github.muqhc:frogui:0.2.0")
}import io.github.muqhc.frogui.*val myPane = borderLayout {
//add component to 'north'
north = JButton("I'm north!")
//add component to 'south'
south = JButton("I'm south!")
//add component to 'center'
center = gridLayout { // add inner panel
layout.columns = 2
//use 'unary plus' to add component
+JButton("I'm the First!")
+flowLayout { // add inner panel
+JButton("[ 1 ]")
+JButton("[ 2 ]")
+JButton("[ 3 ]")
}
}
}class CounterPanel() : JPanel() {
var value = 0
val device = JLabel("$value").apply { horizontalAlignment = JLabel.CENTER }
init {
// ==== Here !!! ====
gridLayout {
layout.rows = 2
+device
+gridLayout {
layout.columns = 2
+JButton("-").apply { addActionListener { update(value - 1) } }
+JButton("+").apply { addActionListener { update(value + 1) } }
}
}
// ==========
}
fun update(value: Int) {
this.value = value
device.text = value.toString()
}
}val customPane = CounterPanel() gridLayout {
layout.rows = 3
+JButton("Reset!").apply { addActionListener { panel.update(0) } }
}

