Adding an image for the item

If the item has an image, we handle it in the same way that we did with the network icon image. This time, though, we actually wrap the ImageView in another HBox before adding it to the outer HBox. We do that so that we can add padding around the image (via picture.setPadding(new Insets()) to give this image some space between it and the network icon.

Finally, we create a Label to hold the item's body. We set the font size of the text to 20 points via label.setFont(Font.font(null, 20)), and add it to our HBox, which we then return to the caller, updateItem().

Any time you have a ListView, you are likely going to want a custom ListCell implementation like we have here. In some cases, calling toString() on the ...

Get Java 9: Building Robust Modular Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.