TableView enhancements for JavaFX 2.2

Daniel Zwolenski zonski at
Wed Mar 7 13:18:46 PST 2012

I like the idea of being able to style cells (will have a look at the other
changes later) but might not the index option run into trouble when you
start adding/removing rows/columns? Row 5 becomes row 4 when you delete row
2, so the developer will have to manually adjust the styles.

As a side note, currently I do this sort of styling by using a custom cell
factory and adding a style class on the cell as needed in the updateItem
method (or in a listener that holds onto the reference to the cell). Seems
to work well enough - apart from the issues with adding/removing styles but
that's a separate issue.

On Thu, Mar 8, 2012 at 7:09 AM, Jonathan Giles <jonathan.giles at>wrote:

> Yes, this is true, and I heard it mentioned today elsewhere too. So, there
> has been talk for sometime about validation APIs, etc, and this may one day
> be applicable, but there is also a simpler way that we could do in 2.2. We
> could just add a styleclass to each row in the TableView visible area that
> represents its index, and have both column and row styleclasses in the
> TableCell. I'll have to check with David, our CSS guy, on how much of a
> heart attack this may give him though.
> For example, the third column of a TableView might be column-3 (or
> column-2, I'm not sure if we should count from zero or one), and the third
> row might be row-3 (or row-2). I would then possibly also have the
> TableCell include both style classes, so that you could write something
> like:
> .table-cell:column-3:row-3 {
>   -fx-background-color: red;
> }
> If you wanted to fill all cells in the 5th column with a green fill, you
> could do:
> .table-cell:column-5 {
>  -fx-background-color: green;
> }
> And, of course, if you wanted to fill a row with a blue fill, you could do:
> .table-cell:row-10 {
>   -fx-background-color: blue;
> }
> I think this might be a little painful initially, but when combined with a
> future validation API that knows explicitly about TableView and its
> styleclass approach above, you could get some cool stuff happening fairly
> simply.
> -- Jonathan
> On Thursday, 8 March 2012 10:02:02 a.m., Tom Eugelink wrote:
>> Wat would be interesting is to be able to indicate that a cell as an
>> error, maybe by showing a red border. Or by some overlay.

More information about the openjfx-dev mailing list