容器在验证后不会自动调整大小 [英] Container doesn't resize itself after invoking validate
问题描述
通过 add
和 remove
手动交换组件后,我调用 validate()
放在容器上。根据文档,
After manually swapping components via add
and remove
, I invoke validate()
on the container. According to the documentation,
validate方法用于使容器再次布局其
子组件。在显示容器
之后,修改此容器的
子组件(将其添加到容器中或从容器中删除,或者更改了
与布局相关的信息)时,应调用此方法。
The validate method is used to cause a container to lay out its subcomponents again. It should be invoked when this container's subcomponents are modified (added to or removed from the container, or layout-related information changed) after the container has been displayed.
短语 再次布置其子组件使我认为容器会相应地调整自身大小,但不会。相反,在调用 validate()
之后,我还需要调用 pack()
以便查看其所有子组件。 。
The phrase "lay out its subcomponents again" makes me think that the container will resize itself accordingly, but it doesn't. Instead, after invoking validate()
, I need to invoke pack()
as well in order to view all its subcomponents.
为什么?我是在做错什么吗?
Why is this? Am I doing something wrong?
推荐答案
(可能是由于这种含糊不清,说明在最新的JavaDoc )
(may be due this ambiguity the description is changed in latest javaDoc )
JavaDoc 7 是 NOT 的说法,
validate方法用于引起容器再次布置其子组件 。
The validate method is used to cause a container to lay out its subcomponents again..
而再次需要 pack()
。
请注意 pack()清楚地说,
使此窗口的大小适合其子组件的首选大小和布局。
这篇关于容器在验证后不会自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!