课程: Java for All Platforms: Desktop, Web, and Mobile Development

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Handling button presses

Handling button presses

- [Instructor] So now we're going to finish our desktop application by modifying the on hello button click method to take the value from our text field and then update the welcome text label using a hello message with that value. So the thing we want to note here is the ID of the text field which is just text field with a lowercase t. So let's head over to our HelloController and we'll write the code. So the first thing we need to do is create a reference to our text field. We can follow the pattern that we see for welcome text to do that. Underneath the welcome text field create a new FXML annotation and under that a private text field called text field with a lowercase t. That creates the reference to our FXML object. And then in hello button clicks welcome text.set text method call take that text and replace it with string.format. So this enables us to take a string with placeholders for additional strings in it…

内容