https://kotlinlang.org logo
#codereview
Title
# codereview
d

Daniel Pitts

11/18/2023, 2:03 AM
I'm working on a personal project to create a Kotlin friendly API on top of AWT/Swing. I just created a sample of how to use the menu DSL, and would like some feedback.
Copy code
val openFileAction = action(name = "Open", icon = openIcon) {
    showOpenDialog()
}
// etc...

with(JFrame()) {
    createMenuBar {
        menu("File") {
            item(action = openFileAction)
            // etc...
        }
        addSeparator()
        menu("Edit") {
            item(action = undoAction)
            item(action = redoAction)
            addSeparator()
            item(action = deleteAction)
            // etc...
        }
    }
}
p

Paul Griffith

11/21/2023, 5:21 PM
as a swing programmer looks pretty good me I’ve had a similar idea in mind (I even wrote a very similar Action wrapper) but never executed on it for menu
👍 1
d

Daniel Pitts

11/21/2023, 5:27 PM
Thanks. I’m also kind of proud of the Hints DSL I wrote, and some of the stuff in the geom package.
p

Paul Griffith

11/21/2023, 5:32 PM
it looks like your repo is currently private
d

Daniel Pitts

11/21/2023, 5:32 PM
Oh, let me change that.
p

Paul Griffith

11/21/2023, 5:33 PM
my action wrapper is a full on subclass rather than a nicer constructor, but the property delegates were fun: https://github.com/inductiveautomation/kindling/blob/main/src/main/kotlin/io/github/inductiveautomation/kindling/utils/Action.kt
d

Daniel Pitts

11/21/2023, 5:35 PM
I've made my repo public. It's definitely not ready for general consumption, but any feedback is welcome.