FocusModel too restricted?

Werner Lehmann lehmann at
Sun Sep 1 05:25:35 PDT 2013


I am trying to use FocusModel in a custom property sheet component - it 
is probably a good idea to reuse as much API as possible and make 
components work similar to each other. However, the focus model makes 
this more difficult than it should be:

1. Why is it index-based? With methods like focusNext and focusPrevious 
it should not really require an ordered, index-based list. The TreeView 
focus model shows how this requires non-trivial extra effort if the data 
model is not similar to a plain list.

2. Why is setFocusedItem package private and final? With this I cannot 
even provide a new method "focus(item)" because I cannot call 
setFocusedItem internally. My users would have to translate their item 
into an index to be able to focus it. The TableViewFocusModel seems to 
have the same problem - but it is in the same package and can simply 
cheat on package private methods!

To make this still work I'd have to provide index-based access to a 
tree-like data model. And to allow operations like focus(item) I'd have 
to translate the item to an index to call focus(index) instead - 
although I don't even need that index, and providing it is extra effort.

Does it make sense to lift some of these restrictions?
- no index-based requirement
- less final/package-private methods

Similar things can be said about the selection model...


More information about the openjfx-dev mailing list