Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Focus table cell content

1047436Feb 8 2014 — edited Feb 13 2014

Hi,

I have a custom cell factory that provides table cells with text boxes and other controls inside - but unlike the default TextFieldTableCell they are always in edit mode or more precisely they don't use edit mode but always render a text field that is bound to the model.

After adding a new row to the table, I want to focus the first cell/column, so that the user can immediately start filling in the contents. However, both of my ideas to do that failed:

Using the FocusModel of the table did not work:

table.requestFocus();

table.getFocusModel().focus(newRowIndex, firstColumn);

The entire row is highlighted (not as "selected" but as "focused"), but the text field *inside* the table cell is not focused.

So I would need something like:

table.getCell(newRowIndex, firstColumn).getGraphic().requestFocus()

but that does not exist:

For UI tests, I have a rather hacky solution similar to the cell()-Method here: https://github.com/SmartBear/TestFX/blob/master/src/main/java/org/loadui/testfx/controls/TableViews.java But I don't want something like that in my actual application code.

Are there any other possibilities to achieve this?

Thanks for any help!

Philipp

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 13 2014
Added on Feb 8 2014
1 comment
1,619 views