Skip to content

Commit d31b70e

Browse files
committed
Add JavaFX demo applications and .gitignore files for jbang and kts
1 parent ee33bcd commit d31b70e

File tree

5 files changed

+104
-0
lines changed

5 files changed

+104
-0
lines changed

material/scripting/jbang/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

material/scripting/jbang/jfxdemo.kt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
3+
//DEPS org.openjfx:javafx-controls:23
4+
//DEPS org.openjfx:javafx-graphics:23:${os.detected.jfxname}
5+
//DEPS org.openjfx:javafx-fxml:23
6+
7+
import javafx.application.Application
8+
import javafx.geometry.Pos
9+
import javafx.scene.Scene
10+
import javafx.scene.control.Label
11+
import javafx.scene.layout.VBox
12+
import javafx.stage.Stage
13+
14+
class HelloJFXApp : Application() {
15+
private var scene: Scene? = null
16+
17+
override fun start(stage: Stage) {
18+
val javaInfoString = String.format(
19+
"Java: %s, %s , %s",
20+
System.getProperty("java.version"),
21+
System.getProperty("java.vendor"),
22+
System.getProperty("java.vm.version")
23+
)
24+
val jfxInfoString = String.format("JavaFX: %s", System.getProperty("javafx.version"))
25+
26+
val holder = VBox()
27+
holder.isFillWidth = true
28+
holder.alignment = Pos.TOP_CENTER
29+
holder.spacing = 5.0
30+
holder.children.addAll(
31+
Label(javaInfoString),
32+
Label(jfxInfoString),
33+
)
34+
35+
scene = Scene(holder, 400.0, 300.0)
36+
stage.title = "JavaFX Demo"
37+
stage.scene = scene
38+
stage.show()
39+
}
40+
}
41+
42+
fun main() {
43+
Application.launch(HelloJFXApp::class.java)
44+
}

material/scripting/kts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@file:CompilerOptions("-jvm-target", "1.8", "-Xabi-stability=unstable")
2+
3+
interface Test {
4+
fun print()
5+
fun printSuper() = println("Hi from super")
6+
}
7+
8+
class TestImpl : Test {
9+
override fun print() = println("Hi from sub")
10+
}
11+
12+
fun printRandom() = println("Hi from random")
13+
14+
TestImpl().run {
15+
print()
16+
printSuper()
17+
printRandom()
18+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@file:DependsOn("org.openjfx:javafx-controls:23")
2+
@file:DependsOn("org.openjfx:javafx-graphics:23")
3+
4+
import javafx.application.Application
5+
import javafx.geometry.Pos
6+
import javafx.scene.Scene
7+
import javafx.scene.control.Label
8+
import javafx.scene.layout.VBox
9+
import javafx.stage.Stage
10+
11+
12+
class HelloJFXApp : Application() {
13+
private var scene: Scene? = null
14+
15+
override fun start(stage: Stage) {
16+
val javaInfoString = String.format(
17+
"Java: %s, %s , %s",
18+
System.getProperty("java.version"),
19+
System.getProperty("java.vendor"),
20+
System.getProperty("java.vm.version")
21+
)
22+
val jfxInfoString = String.format("JavaFX: %s", System.getProperty("javafx.version"))
23+
24+
val holder = VBox()
25+
holder.isFillWidth = true
26+
holder.alignment = Pos.TOP_CENTER
27+
holder.spacing = 5.0
28+
holder.children.addAll(
29+
Label(javaInfoString),
30+
Label(jfxInfoString),
31+
)
32+
33+
scene = Scene(holder, 400.0, 300.0)
34+
stage.title = "JavaFX Demo"
35+
stage.scene = scene
36+
stage.show()
37+
}
38+
}
39+
40+
Application.launch(HelloJFXApp::class.java)

0 commit comments

Comments
 (0)