<Swing Dev> RFR: 8272148: JDesktopPane:getComponentCount() returns one extra than expected with GTKLookAndFeel

Sergey Bylokhov serb at openjdk.java.net
Mon Aug 23 23:07:29 UTC 2021


On Mon, 23 Aug 2021 16:58:51 GMT, Phil Race <prr at openjdk.org> wrote:

>> A container may include few default components as children, which are added to it during creation. Due to this, calling function getChildrenCount on a new created instance may return non zero value. This behaviour may vary according to L&F also, as some L&F may add some default components to a container, but other L&F may choose not to do so.
>> 
>> The current bugs reports that this behaviour looks suspicious as it is expected that a newly created container will have zero  children.
>> 
>> Current specification is not clear on this whether it is allowed for a container to contain default components or not. The fix make changes to the specification to clarify the same.
>> 
>> Note: I think this will need a CSR, I will file one after the review is completed
>
> src/java.desktop/share/classes/javax/swing/JComponent.java line 185:
> 
>> 183:  * <p>
>> 184:  * Containers inherited from <code>JComponent</code> can contain any
>> 185:  * number of default components as children. This behaviour can also
> 
> can we say "default or initial"

Do we need to say "Containers inherited from JComponent"? For example, JComboBox is just a component, and it is not necessary will be used as a container by the user.
I meant all components inherited from the JComponent are Containers per specification, but not all of them are used as such. And this new statement is applicable to all "JComponents".

-------------

PR: https://git.openjdk.java.net/jdk/pull/5121


More information about the swing-dev mailing list