RFR: JDK-6229853: BasicTextAreaUI:create incompletely documents the possible returned View types
Alexey Ivanov
aivanov at openjdk.org
Tue Sep 27 18:45:26 UTC 2022
On Wed, 21 Sep 2022 12:25:48 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
> API specification says about BasicTextAreaUI.create "Returns a WrappedPlainView or PlainView".
> But for [bidi](https://github.com/openjdk/jdk/blob/d14e96d9701dae951aa365029f58afb6687a646a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextAreaUI.java#L168) text, this method returns BoxView and other views , so the documentation needs to be updated.
Changes requested by aivanov (Reviewer).
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextAreaUI.java line 142:
> 140: * Creates the view for an element. Returns a WrappedPlainView or
> 141: * PlainView if non-bidi text is handled
> 142: * else returns PlainParagraph or BoxView if bidi text is being handled.
You cannot specify that this method returns `PlainParagraph`, it's a private class. I think we should relax the specification to allow other types to be returned without mentioning the exact types.
This issue is also relevant to `BasicTextFieldUI`, yet [it does not state explicitly](https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/plaf/basic/BasicTextFieldUI.html#create(javax.swing.text.Element)) what types are valid, it only gives a hint that a `FieldView` is returned:
> Creates a view (FieldView) based on an element.
So, I propose the following text: *“Creates a view for an element. Usually returns a WrappedPlainView or PlainView.”*
The `@return` tag may be changed to “a view (for the the element)” for this class as well as for `BasicTextFieldUI`.
-------------
PR: https://git.openjdk.org/jdk/pull/10376
More information about the client-libs-dev
mailing list