A Kotlin/Swing GUI example (uses JFrame, JScrollPane, and JTextArea)

Here’s a little Kotlin example that uses Java Swing, including a JFrame, JScrollPane, and JTextArea:

import java.awt.BorderLayout
import java.awt.Dimension
import javax.swing.JFrame
import javax.swing.JScrollPane
import javax.swing.JTextArea

fun main(args: Array<String>) {

    val textArea = JTextArea("Hello, Kotlin/Swing world")
    val scrollPane = JScrollPane(textArea)

    val frame = JFrame("Hello, Kotlin/Swing")
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER)
    frame.setSize(Dimension(600, 400))


Kotlin and Scala are similar in many ways, so this is a simple port of my Scala Swing example.