Chapter 2. JavaFX Script data and variables

 

This chapter covers

  • Introducing JavaFX Script variables
  • Doing interesting things to strings
  • Getting linear, with ranges and sequences
  • Automating variable updates using binds

If chapter 1 has had the desired effect, you should be eager to get your hands dirty with code. But before we can start dazzling unsuspecting bystanders with our stunning JavaFX visuals, we’ll need to become acquainted with Java FX Script, JavaFX’s own programming language. In this chapter, and the one that follows, we’ll start to do just that.

In this chapter we will look at how variables are created and manipulated. JavaFX Script has a lot of interesting features in this area, beyond those offered by languages like Java or JavaScript, such as sophisticated array manipulation and the ability to bind variables into automatic update relationships. By the end of this chapter you’ll understand how these features work, so in the next chapter we can explore how they integrate into standard programming constructs like loops, conditions, and classes.

In writing this tutorial I’ve attempted to create a smooth progression through the language, with later sections building on the knowledge gleaned from previous reading. This logical progression wasn’t always possible, and occasionally later detail bleeds into earlier sections.


Quick Start

2.1. Annotating code with comments

2.2. Data types

2.3. Working with text, via strings

2.4. Durations, using time literals

2.5. Sequences: not quite arrays

2.6. Autoupdating related data, with binds

2.7. Working nicely with Java

2.8. Summary

sitemap