Java Reference
In-Depth Information
public static void main(String[] args) {
launch(args);
}
}
Listing 3-25. Product.java
public class Product {
private String category;
private String name;
private String description;
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
In this IncludeExample program, we build up the UI in two FXML files, each one backed by its own
controller. The UI features a TreeTableView on the left side, and some Label s and a TextArea on the right side.
The TreeTableView is loaded with dummy Product data. When a row in the left TreeTableView is selected, the
corresponding Product is shown on the right side. You can edit the Product 's description field using the TextArea on
the right side. As you navigate away from an old row to a new row on the left side, the Product on the right side reflects
the change. However, all the changes that you made to previously displayed Product s are retained in the model. When
you navigate back to a modified Product , your changes will be shown again. The TreeTableView class is covered in
more detail in Chapter 6.
We used a ChangeListener<String> that is attached to the TextField 's textProperty to synchronize the text
in the TextField and the description in the Product . JavaFX properties and change listeners are part of the JavaFX
Properties and Bindings API. We cover this API in the next chapter.
When the IncludeExample is run, the Include Example window shown in Figure 3-7 is displayed.
Search WWH ::




Custom Search