SWT label size is not correctly updated

无人久伴 提交于 2019-12-05 19:56:38

Try to call parent.layout(), where parent is the Composite which contains your label. Also see Understanding Layouts in SWT.

I know this is old, but in order to not lose any LayoutData settings that may be set on the controls. You should call getParent().requestLayout(). The documentation specifically discourages the user of getParent().layout() which loses all the cached Data settings on the controls.

Use of this method is discouraged since it is the least-efficient way to trigger a layout. The use of layout(true) discards all cached layout information, even from controls which have not changed. It is much more efficient to invoke Control.requestLayout() on every control which has changed in the layout than it is to invoke this method on the layout itself.

Based on the documentation of getParent().layout(), you should call requestLayout() on the control itself not its parent as @kingargyle said.

What I always did was label.requestLayout() and it worked flawlessly.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!