diff --git a/jbang-catalog.json b/jbang-catalog.json new file mode 100644 index 0000000..0b4983a --- /dev/null +++ b/jbang-catalog.json @@ -0,0 +1,25 @@ +{ + "catalogs": {}, + "aliases": { + "jfxapp": { + "script-ref": "material/scripting/jbang/jfxdemo.kt", + "description": "Single file JavaFX application that defined the UI with code (no fxml)" + } + }, + "templates": { + "jfxkt-legacy": { + "file-refs": { + "{basename}.kt": "material/scripting/jbang/jfxdemo.kt" + }, + "description": "Single file JavaFX application", + "properties": {} + }, + "jfxkt": { + "file-refs": { + "{basename}.kt": "material/scripting/jbang/jfxdemo.qute" + }, + "description": "Single file JavaFX application that defined the UI with code (no fxml)", + "properties": {} + } + } +} diff --git a/material/scripting/jbang/.gitignore b/material/scripting/jbang/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/material/scripting/jbang/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/material/scripting/jbang/jfxdemo.kt b/material/scripting/jbang/jfxdemo.kt new file mode 100644 index 0000000..cf8c481 --- /dev/null +++ b/material/scripting/jbang/jfxdemo.kt @@ -0,0 +1,44 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? + +//DEPS org.openjfx:javafx-controls:23 +//DEPS org.openjfx:javafx-graphics:23:${os.detected.jfxname} +//DEPS org.openjfx:javafx-fxml:23 + +import javafx.application.Application +import javafx.geometry.Pos +import javafx.scene.Scene +import javafx.scene.control.Label +import javafx.scene.layout.VBox +import javafx.stage.Stage + +class HelloJFXApp : Application() { + private var scene: Scene? = null + + override fun start(stage: Stage) { + val javaInfoString = String.format( + "Java: %s, %s , %s", + System.getProperty("java.version"), + System.getProperty("java.vendor"), + System.getProperty("java.vm.version") + ) + val jfxInfoString = String.format("JavaFX: %s", System.getProperty("javafx.version")) + + val holder = VBox() + holder.isFillWidth = true + holder.alignment = Pos.TOP_CENTER + holder.spacing = 5.0 + holder.children.addAll( + Label(javaInfoString), + Label(jfxInfoString), + ) + + scene = Scene(holder, 400.0, 300.0) + stage.title = "JavaFX Demo" + stage.scene = scene + stage.show() + } +} + +fun main() { + Application.launch(HelloJFXApp::class.java) +} \ No newline at end of file diff --git a/material/scripting/jbang/jfxdemo.qute b/material/scripting/jbang/jfxdemo.qute new file mode 100644 index 0000000..4e6935d --- /dev/null +++ b/material/scripting/jbang/jfxdemo.qute @@ -0,0 +1,44 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? + +//DEPS org.openjfx:javafx-controls:23 +//DEPS org.openjfx:javafx-graphics:23:${os.detected.jfxname} +//DEPS org.openjfx:javafx-fxml:23 + +import javafx.application.Application +import javafx.geometry.Pos +import javafx.scene.Scene +import javafx.scene.control.Label +import javafx.scene.layout.VBox +import javafx.stage.Stage + +class {baseName} : Application() { + private var scene: Scene? = null + + override fun start(stage: Stage) { + val javaInfoString = String.format( + "Java: %s, %s , %s", + System.getProperty("java.version"), + System.getProperty("java.vendor"), + System.getProperty("java.vm.version") + ) + val jfxInfoString = String.format("JavaFX: %s", System.getProperty("javafx.version")) + + val holder = VBox() + holder.isFillWidth = true + holder.alignment = Pos.TOP_CENTER + holder.spacing = 5.0 + holder.children.addAll( + Label(javaInfoString), + Label(jfxInfoString), + ) + + scene = Scene(holder, 400.0, 300.0) + stage.title = "JavaFX Demo" + stage.scene = scene + stage.show() + } +} + +fun main() { + Application.launch(HelloJFXApp::class.java) +} \ No newline at end of file diff --git a/material/scripting/jbang/testjfx.kt b/material/scripting/jbang/testjfx.kt new file mode 100644 index 0000000..cf8c481 --- /dev/null +++ b/material/scripting/jbang/testjfx.kt @@ -0,0 +1,44 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? + +//DEPS org.openjfx:javafx-controls:23 +//DEPS org.openjfx:javafx-graphics:23:${os.detected.jfxname} +//DEPS org.openjfx:javafx-fxml:23 + +import javafx.application.Application +import javafx.geometry.Pos +import javafx.scene.Scene +import javafx.scene.control.Label +import javafx.scene.layout.VBox +import javafx.stage.Stage + +class HelloJFXApp : Application() { + private var scene: Scene? = null + + override fun start(stage: Stage) { + val javaInfoString = String.format( + "Java: %s, %s , %s", + System.getProperty("java.version"), + System.getProperty("java.vendor"), + System.getProperty("java.vm.version") + ) + val jfxInfoString = String.format("JavaFX: %s", System.getProperty("javafx.version")) + + val holder = VBox() + holder.isFillWidth = true + holder.alignment = Pos.TOP_CENTER + holder.spacing = 5.0 + holder.children.addAll( + Label(javaInfoString), + Label(jfxInfoString), + ) + + scene = Scene(holder, 400.0, 300.0) + stage.title = "JavaFX Demo" + stage.scene = scene + stage.show() + } +} + +fun main() { + Application.launch(HelloJFXApp::class.java) +} \ No newline at end of file diff --git a/material/scripting/jbang/testjfx2.kt b/material/scripting/jbang/testjfx2.kt new file mode 100644 index 0000000..34599d9 --- /dev/null +++ b/material/scripting/jbang/testjfx2.kt @@ -0,0 +1,44 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? + +//DEPS org.openjfx:javafx-controls:23 +//DEPS org.openjfx:javafx-graphics:23:$NOT_FOUND +//DEPS org.openjfx:javafx-fxml:23 + +import javafx.application.Application +import javafx.geometry.Pos +import javafx.scene.Scene +import javafx.scene.control.Label +import javafx.scene.layout.VBox +import javafx.stage.Stage + +class testjfx2 : Application() { + private var scene: Scene? = null + + override fun start(stage: Stage) { + val javaInfoString = String.format( + "Java: %s, %s , %s", + System.getProperty("java.version"), + System.getProperty("java.vendor"), + System.getProperty("java.vm.version") + ) + val jfxInfoString = String.format("JavaFX: %s", System.getProperty("javafx.version")) + + val holder = VBox() + holder.isFillWidth = true + holder.alignment = Pos.TOP_CENTER + holder.spacing = 5.0 + holder.children.addAll( + Label(javaInfoString), + Label(jfxInfoString), + ) + + scene = Scene(holder, 400.0, 300.0) + stage.title = "JavaFX Demo" + stage.scene = scene + stage.show() + } +} + +fun main() { + Application.launch(HelloJFXApp::class.java) +} \ No newline at end of file diff --git a/material/scripting/kts/.gitignore b/material/scripting/kts/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/material/scripting/kts/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/material/scripting/kts/compiler-options.main.kts b/material/scripting/kts/compiler-options.main.kts new file mode 100644 index 0000000..feb19ec --- /dev/null +++ b/material/scripting/kts/compiler-options.main.kts @@ -0,0 +1,18 @@ +@file:CompilerOptions("-jvm-target", "1.8", "-Xabi-stability=unstable") + +interface Test { + fun print() + fun printSuper() = println("Hi from super") +} + +class TestImpl : Test { + override fun print() = println("Hi from sub") +} + +fun printRandom() = println("Hi from random") + +TestImpl().run { + print() + printSuper() + printRandom() +} \ No newline at end of file diff --git a/material/scripting/kts/jfxdemo.main.kts b/material/scripting/kts/jfxdemo.main.kts new file mode 100644 index 0000000..a0ba082 --- /dev/null +++ b/material/scripting/kts/jfxdemo.main.kts @@ -0,0 +1,40 @@ +@file:DependsOn("org.openjfx:javafx-controls:23") +@file:DependsOn("org.openjfx:javafx-graphics:23") + +import javafx.application.Application +import javafx.geometry.Pos +import javafx.scene.Scene +import javafx.scene.control.Label +import javafx.scene.layout.VBox +import javafx.stage.Stage + + +class HelloJFXApp : Application() { + private var scene: Scene? = null + + override fun start(stage: Stage) { + val javaInfoString = String.format( + "Java: %s, %s , %s", + System.getProperty("java.version"), + System.getProperty("java.vendor"), + System.getProperty("java.vm.version") + ) + val jfxInfoString = String.format("JavaFX: %s", System.getProperty("javafx.version")) + + val holder = VBox() + holder.isFillWidth = true + holder.alignment = Pos.TOP_CENTER + holder.spacing = 5.0 + holder.children.addAll( + Label(javaInfoString), + Label(jfxInfoString), + ) + + scene = Scene(holder, 400.0, 300.0) + stage.title = "JavaFX Demo" + stage.scene = scene + stage.show() + } +} + +Application.launch(HelloJFXApp::class.java) \ No newline at end of file diff --git a/material/scripting/kts/ktor-demo.main.kts b/material/scripting/kts/ktor-demo.main.kts new file mode 100644 index 0000000..e69de29