Skip to content

Instantly share code, notes, and snippets.

@holgerbrandl
Last active September 14, 2018 07:48
Show Gist options
  • Save holgerbrandl/a4566b12d6f9f9921169f1edfe65f81b to your computer and use it in GitHub Desktop.
Save holgerbrandl/a4566b12d6f9f9921169f1edfe65f81b to your computer and use it in GitHub Desktop.
Swing integration example without using unnecessary JFrame
import javafx.application.Platform
import javafx.beans.property.SimpleObjectProperty
import javafx.embed.swing.JFXPanel
import javafx.scene.image.Image
import javafx.stage.Stage
import tornadofx.*
import javax.swing.SwingUtilities
object SwingApp {
private fun createAndShowGUI() {
SwingUtilities.invokeLater {
JFXPanel() // this will prepare JavaFX toolkit and environment
Platform.runLater {
val stage = Stage()
val app = HelloWorldApp()
app.start(stage)
}
}
}
@JvmStatic
fun main(args: Array<String>) {
createAndShowGUI()
}
}
class PlottingPanel : View() {
val imageProperty = SimpleObjectProperty<Image>()
override val root = pane {
label("foo")
}
}
class HelloWorldApp : App(PlottingPanel::class, InternalWindow.Styles::class)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment