Last active
September 14, 2018 07:48
-
-
Save holgerbrandl/a4566b12d6f9f9921169f1edfe65f81b to your computer and use it in GitHub Desktop.
Swing integration example without using unnecessary JFrame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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