Set Font globally in JavaFX

后端 未结 3 1684
攒了一身酷
攒了一身酷 2020-12-09 11:00

How can I set the Font type globally in a JavaFX application?

Is there any solution that I can use? In JavaFX 8 the default Font has changed, and I would like to us

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 11:30

    Just a TornadoFX example

    package bj
    
    import tornadofx.*
    
    class MyView : View() {
        override val root = vbox {
            button("天地玄黄")
            button("宇宙洪荒")
        }
    }
    
    class MyStylesheet : Stylesheet() {
        init {
            root {
                fontFamily = "Noto Sans CJK SC Regular"
            }
        }
    }
    
    class MyApp : App(MyView::class, MyStylesheet::class)
    
    fun main(args: Array) {
        launch(*args)
    }
    

提交回复
热议问题