在SWT树或表中嵌入自定义小部件 [英] Embed custom widget in SWT Tree or Table

查看:442
本文介绍了在SWT树或表中嵌入自定义小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用SWT,是否可以创建自定义窗口小部件并将其插入,就像它是 TreeItem TableItem

Using SWT, Is it possible to create a custom widget and insert it to a Table or Tree as if it was a TreeItem or TableItem?

我试过创建一个类并扩展 TreeItem 但是我收到了这个警告:

I tried to create a class and extend TreeItem but I'm getting this warning:

MyClass illegally extends TreeItem

有没有办法做到这一点?

Is there a way to do this?

推荐答案

大多数SWT小部件都不是为扩展而设计的,并通过检查当前类是否位于 org.eclipse.swt中来强制执行此操作.widgets 包。这可以解决,但非常强烈建议不要这样做。

Most SWT widgets are not designed to be extended and enforce this by checking that the current class is in the org.eclipse.swt.widgets package. This can be worked around but is very strongly discouraged.

小部件通常包含许多特定于平台的代码,覆盖类可能很容易最终使用只能工作的代码在一个平台上。

Widgets generally contain a lot of platform specific code, an override class might very easily end up using code which will only work on one platform.

还有各种其他方法来扩展表和树。使用 TableEditor TreeEditor 是一种方法。使用 SWT.MeasureItem SWT.PaintItem SWT.EraseItem自己绘制表/树是另一个。

There are various other ways to extend tables and trees. Using TableEditor and TreeEditor is one way. Drawing the table/tree yourself using SWT.MeasureItem, SWT.PaintItem and SWT.EraseItem is another.

这篇关于在SWT树或表中嵌入自定义小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆