Commit 87a96399 authored by Nikolay Igotti's avatar Nikolay Igotti

Exit sample on close by default

parent 7f4e7a88
......@@ -19,17 +19,19 @@ import java.nio.file.Files
import javax.imageio.ImageIO
fun main(args: Array<String>) {
repeat(1) {
createWindow("window $it")
val windows = 1
repeat(windows) {
createWindow("window $it", windows == 1)
}
}
fun createWindow(title: String) = runBlocking(Dispatchers.Swing) {
fun createWindow(title: String, exitOnClose: Boolean) = runBlocking(Dispatchers.Swing) {
var mouseX = 0
var mouseY = 0
val window = SkiaWindow()
window.defaultCloseOperation = WindowConstants.DISPOSE_ON_CLOSE
window.defaultCloseOperation =
if (exitOnClose) WindowConstants.EXIT_ON_CLOSE else WindowConstants.DISPOSE_ON_CLOSE
window.title = title
// Create menu.
......
......@@ -11,7 +11,7 @@ fun pureSwing() {
window.contentPane.add(Button("Skiko").apply {
addActionListener {
createWindow("Skiko")
createWindow("Skiko", false)
}
}, BorderLayout.NORTH)
window.contentPane.add(Button("Swing").apply {
......
......@@ -75,7 +75,7 @@ fun SwingSkia() = SwingUtilities.invokeLater {
Button(
text = "New Window",
action = {
createWindow("ComposeWindow")
createWindow("ComposeWindow", false)
}
),
BorderLayout.SOUTH
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment