javafx框架tornadofx入门实战 计算Sha256

代码语言: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
    }
}</code></pre></div></div><figure class=""><div class="rno-markdown-img-url" style="text-align:center"><div class="rno-markdown-img-url-inner" style="width:100%"><div style="width:100%"><img src="https://cdn.static.attains.cn/app/developer-bbs/upload/1723280583121697035.png" /></div><div class="figure-desc">image.png</div></div></div></figure>