前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >java SWT:最有效的layout方法Control.requestLayout()

java SWT:最有效的layout方法Control.requestLayout()

作者头像
10km
发布2019-05-25 21:38:16
7710
发布2019-05-25 21:38:16
举报
文章被收录于专栏:10km的专栏10km的专栏

版权声明:本文为博主原创文章,转载请注明源地址。 https://cloud.tencent.com/developer/article/1433536

Eclipse SWT最新的版本中org.eclipse.swt.widgets.Control增加了一个新方法requestLayout()用于更高效的处理layout请求

该方法其实只有一行代码:

代码语言:javascript
复制
public void requestLayout () {
    getShell ().layout (new Control[] {this}, SWT.DEFER);
}

这是SWT当前最高效的触发layout的办法,但是目前大多数开发者还是习惯使用性能更差的 Composite.layout()方法,

下面是说明原文:

SWT has added a new requestLayout() method to the Control and Composite classes. This method does essentially the same thing as widget.getShell().layout(new Control[] {widget}, SWT.DEFER);undefined The snippet, above, is currently the most efficient method of triggering layouts in SWT, but most developers are unaware of this. Most Eclipse developers invoke Composite.layout(), which is worse in the sense of performance. This new API is intended to make it easier for developers to adopt the more efficient mechanism as opposed to using Composite#layout(). However, be aware that changing existing invocations of layout() to requestLayout() may break code that assumes that controls are completely sized and positioned at a certain point in time.

参考

《Eclipse Project Neon (4.6) M4 - New and Noteworthy》

《http://www.vogella.com/tutorials/SWT/article.html》

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016年12月03日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档