Natalia Ugolnikova
Natalia Ugolnikova

Reputation: 13

Load .txt file tornadoFx Kotlin

I have recently started to study TornadoFX. And I need to write a program, which would read txt file (single file) with math operations and then write an answer.

I have created a button that opens Explorer to load the file, but I can't choose a file. What do I need to do about it?

Here is my code :

class MainView : View("Calculate") {

    var resultText = SimpleStringProperty()

    override val root = vbox {
        this.alignment = Pos.CENTER
        spacing = 20.0

        label (
        text = "Upload file with extension(.txt)")

        button("open") {
            action {
                action {
                    var dir = chooseDirectory("Choose a file")
                }
            }
        }

        label(resultText){
            bind (resultText)
            text = "Here you see the answer"
        }
    }
}

Here are pictures of the app:

enter image description here

Upvotes: 1

Views: 91

Answers (0)

Related Questions