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 ...@@ -19,17 +19,19 @@ import java.nio.file.Files
import javax.imageio.ImageIO import javax.imageio.ImageIO
fun main(args: Array<String>) { fun main(args: Array<String>) {
repeat(1) { val windows = 1
createWindow("window $it") 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 mouseX = 0
var mouseY = 0 var mouseY = 0
val window = SkiaWindow() 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 window.title = title
// Create menu. // Create menu.
......
...@@ -11,7 +11,7 @@ fun pureSwing() { ...@@ -11,7 +11,7 @@ fun pureSwing() {
window.contentPane.add(Button("Skiko").apply { window.contentPane.add(Button("Skiko").apply {
addActionListener { addActionListener {
createWindow("Skiko") createWindow("Skiko", false)
} }
}, BorderLayout.NORTH) }, BorderLayout.NORTH)
window.contentPane.add(Button("Swing").apply { window.contentPane.add(Button("Swing").apply {
......
...@@ -75,7 +75,7 @@ fun SwingSkia() = SwingUtilities.invokeLater { ...@@ -75,7 +75,7 @@ fun SwingSkia() = SwingUtilities.invokeLater {
Button( Button(
text = "New Window", text = "New Window",
action = { action = {
createWindow("ComposeWindow") createWindow("ComposeWindow", false)
} }
), ),
BorderLayout.SOUTH 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