Beans绑定NetBeans中的JTable [英] BeansBinding a JTable in NetBeans
问题描述
我想将一个bean列表映射到JTable。我们的想法是每个列都是bean中的一个预选字段,每一行都是List中的一个bean。 Slide#32在这里看起来非常有前景: http:// swinglabs。 org / docs / presentations / 2007 / DesktopMatters / beans-binding-talk.pdf
I want map a List of beans to a JTable. The idea is that each column will be a preselected field in the bean and each row will be a bean in the List. Slide #32 here looks very promising: http://swinglabs.org/docs/presentations/2007/DesktopMatters/beans-binding-talk.pdf
然而,NetBeans在让我分配bean字段方面不是很友好到一个专栏。我可以右键单击JTable并单击Bind-> Elements并将其绑定到我的Bean列表。但是,它不会让我指定每列中的内容。唯一的选择就是自己创建绑定,这使得NetBeans对这类事物毫无用处。
However, NetBeans is not very friendly in letting me assign a bean field to a column. I can right-click the JTable and click Bind->Elements and bind it to my List of beans. However, it will not let me specify what goes in each column. The only option is to create the binding myself which pretty much makes NetBeans useless for this type of thing.
我是否缺少一个细节?似乎NetBeans中的JTable BeansBinding刚刚破解。
Is there a detail I'm missing? It appears that JTable BeansBinding in NetBeans is just broken.
谢谢
推荐答案
<我有它的工作。您无法真正使用JTables的绑定菜单选项。以下是如何使其工作:
I have it working. You can't really use the "Bind" menu option for JTables. Here's how to get it to work:
- 右键单击JTable。
- 点击表格内容。
- Right-Click the JTable.
- Click "Table Contents".
- 绑定来源:表格
- 绑定表达式:$ {var}(其中var是列表的名称bean)。
注意:映射到列的每个字段必须具有一个吸气剂。
Note: Each field mapped to a column must have a getter.
这篇关于Beans绑定NetBeans中的JTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!