TornadoFX大杂烩

栏目: Java · 发布时间: 7年前

内容简介:注意:文章首发:
compile 'no.tornado:tornadofx:1.7.17'
compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

HelloWorld

import javafx.application.Application
import tornadofx.*

class App:tornadofx.App(MainView::class,MainStylesheet::class)

class MainView:View() {
    override val root = vbox {
        label("Hello World")
    }
}

class MainStylesheet:Stylesheet() {
    init {
        label {
            fontSize = 20.px
        }
    }
}

fun main(args:Array<String>) {
    Application.launch(App::class.java,*args)
}

进阶之Observable

import javafx.application.Application
import javafx.collections.FXCollections
import tornadofx.*

class App:tornadofx.App(MainView::class,MainStylesheet::class)

class Person(id: Int, name: String) {
    var id: Int by property(id)
    var name: String by property(name)
}

class MainView:View() {
    private val persons = FXCollections.observableArrayList(
            Person(10, "Ant"),
            Person(20, "Bee"),
            Person(30, "Cat")
    )
    override val root = tableview(persons) {
        column("ID", Person::id)
        column("name", Person::name)
    }
}

class MainStylesheet:Stylesheet() {
    init {
        label {
            fontFamily = "Noto Sans CJK SC Medium"
            fontSize = 20.px
        }
    }
}

fun main(args:Array<String>) {
    Application.launch(App::class.java,*args)
}

注意:

  • JavaFX可能对中文支持不好,最要手动设置中g字体

文章首发: https://baijifeilong.github.io


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

编程卓越之道

编程卓越之道

海德 / 张菲 / 电子工业出版社 / 2007-4 / 69.00元

《编程卓越之道第二卷:运用底层语言思想编写高级语言代码》是《编程卓越之道》系列书的第二卷,将探讨怎样用高级语言(而非汇编语言)编程得到高效率机器代码。在书中,您可以学到如何分析编译器的输出,以便检验代码的所作所为,从而得到高质量的机器码;了解编译器为常见控制结构生成的典型机器指令,以便在编写高级语言程序时选用恰当的语句;掌握编译器将各种常量和变量类型转换成机器数据的方法,以便于使用这些数据写出又快......一起来看看 《编程卓越之道》 这本书的介绍吧!

SHA 加密
SHA 加密

SHA 加密工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具