Maximilian Conroe Maximilian Conroe - 5 months ago 20
Java Question

How do I use the table header for entries an a row for properties in JavaFX

while writing my first JavaFX application I already encountered a problem which I am unfortunately not able to solve myself. I'm trying to change the orientation of a datatable to horizontal, rather than vertical.

The table header should therefore be located on the left hand side while the data records should be displayed in columns rather than rows.
The result should look like this:

desired result


I'm using scene graph to design my scenes and therefore also fxml. If possible, I'd like to stick to this approach, but if push comes to shove I'd be willing to create the table directly in javacode.

Thanks in advance!

Answer

There's no built-in way to do what you describe. TableViews are not symmetrical: the list of items in the table are always represented as the rows of the table, and column data are represented as mapping from each row object to a property. The header is always a column header.

You might consider SpreadsheetView from ControlsFX, which might give you the functionality you need.