英文:
SWT composite resize
问题
我正在制作一个应用程序,在其中我有一个复合组件,里面包含另一个带有一些按钮的复合组件。问题是,当我调整带有按钮的复合组件的大小时,有时按钮会被隐藏起来。我通过将composite.layout()
替换为composite.requestLayout()
方法来解决了这个问题。这两种方法有什么区别,为什么使用requestLayout()
可以正常工作,而使用layout()
有时可以正常工作?从我所见,它们基本上是相似的。
谢谢!
英文:
I am making an application in which I have a Composite, which has inside another composite with a few buttons. The thing is, when I resize the composite with the buttons, sometimes, the buttons are being hided. I solved this by replacing composite.layout() with composite.requestLayout() method. What is the difference between those 2 methods and why it's working fine with the requestLayout() and just sometimes with layout(), from what I've seen they are pretty much similar.
Thank you!
答案1
得分: 0
Composite.layout
请求重新布局复合控件及其子控件。如果复合控件的内容变得更大,它不会告诉复合控件的父级需要更多的空间,因此某些内容可能会被隐藏。
Composite.requestLayout
(实际上是Control.requestLayout
)请求重新布局Shell
中控件的所有祖先控件(这是异步完成的)。这将调整所有必要的内容以腾出空间。
英文:
Composite.layout
requests that the composite and its children should be layed out again. If the composite's contents get bigger it does not tell the parent of the composite that it needs more space so some things may end up hidden.
Composite.requestLayout
(actually Control.requestLayout
) requests that all the ancestor controls of the control in the Shell
should be layed out again (this is done asynchronously). This will adjust everything necessary to make space.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论