Skip to content

Commit

Permalink
Some JBang templates and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
yostane committed Nov 30, 2024
1 parent d31b70e commit 2ca1a9a
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 0 deletions.
25 changes: 25 additions & 0 deletions jbang-catalog.json
Original file line number Diff line number Diff line change
@@ -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 that defined the UI with code (no fxml)"
},
"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": {}
}
}
}
44 changes: 44 additions & 0 deletions material/scripting/jbang/jfxdemo.qute
Original file line number Diff line number Diff line change
@@ -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)
}
44 changes: 44 additions & 0 deletions material/scripting/jbang/testjfx.kt
Original file line number Diff line number Diff line change
@@ -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)
}
44 changes: 44 additions & 0 deletions material/scripting/jbang/testjfx2.kt
Original file line number Diff line number Diff line change
@@ -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)
}
Empty file.

0 comments on commit 2ca1a9a

Please sign in to comment.