javafx框架tornadofx入门实战 计算Sha256

2020-02-14 18:19:44 浏览数 (2)

代码语言:txt复制
class FxHashingView : View("javafx框架tornadofx入门实战 计算Sha256") {
    val str0 = stringProperty()
    val strHash = stringProperty()
    val fpath = stringProperty()
    val fileContent = stringProperty()
    override val root = vbox(5) {
        hbox(5) {
            label("Sha256:")
            textfield(strHash) {
                promptText = "Sha256 hashing string"
                isEditable = false
                str0.onChange {
                    strHash.value = calcuteSha256(str0.value)
                }
                hgrow = Priority.ALWAYS
            }
        }
        textarea(str0) {
            promptText = "input string here"
            hgrow = Priority.ALWAYS

        }
        button("choose file") {
            action {
                _chooseFile()
                strHash.value = calcuteSha256(File(fpath.value))
                fileContent.value = File(fpath.value).readText()
            }
        }
        textarea(fileContent) {
            vgrow = Priority.ALWAYS
            promptText = "显示文件内容"
        }
        setPrefSize(700.0, 700.0)
        paddingAll = 10.0
        style {
            fontSize = 16.px
        }
    }
image.pngimage.png

0 人点赞