On Mon, 28 Jun 2021 15:42:47 GMT, Jeanette Winzenburg <[email protected]>
wrote:
>> modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/TextFieldBehavior.java
>> line 75:
>>
>>> 73: }
>>> 74:
>>> 75: focusListener = (observable, oldValue, newValue) -> {
>>
>> Shouldn't this focusListener also be wrapped in a weakListener? Also this
>> lambda expression can be a one-liner (no braces needed)
>
> we are a bit inconsistent in wrapping (or not) listeners into their weak
> counterparts - behaviors tend to not :) That's okay - and less crowded by
> additional code - as long as they are removed properly, IMO. But just seeing:
> good question, as the focusOwner listener is wrapped, need to consult my
> notes. Thanks for the heads up!
>
> As to the single vs. multiple lines: ersonally, I tend to not change more
> than absolutely needed - it had the brackets before the fix so I kept them.
Okay, went through listener registrations in all behaviors - and they are
indeed inconsistent:
- some listen to control properties like focused (f.i. Button, Combo): adding
strong, often inline listeners
- some listen to control path properties like selection/Model/Indices (f.i.
ListView, TreeView): adding weak (inline or field) wrappers
- cleanup for all guarantees to make those listeners removable (without
touching their type) and actually remove them in dispose
So I tend to follow that approach here as well, opinions?
-------------
PR: https://git.openjdk.java.net/jfx/pull/534