1-14. Creating and Working with Tables

Problem

You want to display items in a UI table control similar to Java Swing’s JTable component.

Solution

Create an application using JavaFX’s javafx.scene.control.TableView class. The TableView control provides the equivalent functionality similar to Swing’s JTable component.

To exercise the TableView control you will be creating an application that will display bosses and employees. On the left you will implement a ListView control containing bosses, and employees (subordinates) will be displayed in a TableView control on the right.

Shown here is the source code of a simple domain (Person) class to represent a boss or an employee to be displayed in a ListView or TableView control:

package javafx2introbyexample.chapter1.recipe1_14; ...

Get JavaFX 2.0: Introduction by Example 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.