Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/muqhc/frogui
the kotlin library providing DSL for Swing
https://github.com/muqhc/frogui
kotlin kotlin-library swing
Last synced: 25 days ago
JSON representation
the kotlin library providing DSL for Swing
- Host: GitHub
- URL: https://github.com/muqhc/frogui
- Owner: muqhc
- License: mit
- Created: 2022-01-14T11:09:36.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-17T06:08:24.000Z (about 3 years ago)
- Last Synced: 2024-11-07T12:12:52.291Z (3 months ago)
- Topics: kotlin, kotlin-library, swing
- Language: Kotlin
- Homepage:
- Size: 925 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# frogui
#### the kotlin library providing DSL for Swing
## add dependency
### Gradle Kotlin DSL
#### build.gradle.kts
```kotlin
repositories {
mavenCentral()
}dependencies {
implementation("io.github.muqhc:frogui:0.2.0")
}
```## examples
### to use....
```kotlin
import io.github.muqhc.frogui.*
```---
### build JPanel (by using frogui dsl)
```kotlin
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 ]")
}
}
}
```
![example_image.png](README_RESOURCES/example_image.png)---
### make your own custom JPanel
```kotlin
class CounterPanel() : JPanel() {
var value = 0val 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()
}
}
```
![example_video.gif](README_RESOURCES/example_video.gif)---
##### ( you can also extend it )
```kotlin
val customPane = CounterPanel() gridLayout {
layout.rows = 3
+JButton("Reset!").apply { addActionListener { panel.update(0) } }
}
```![example_video2.gif](README_RESOURCES/example_video2.gif)
---
### [whole example code](frogui-debug/src/main/kotlin/io/github/muqhc/frogui)