Embed custom widget in SWT Tree or Table

时间秒杀一切 提交于 2019-12-23 03:37:06

问题


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?

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?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/37755860/embed-custom-widget-in-swt-tree-or-table

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