我们可以在JTables中使用通用的TableModel吗? [英] Is there a generic TableModel we can use in JTables?
问题描述
我现在正在调查JTable并且有一堆业务对象,我使用Hibernate +从数据库检索 Spring Data JPA 。
I'm now looking into JTables and have a bunch of business objects that I retrieve from the DB with Hibernate + Spring Data JPA.
我喜欢Spring Data JPA处理DAL的所有繁琐实现,并且想知道是否有类似的东西 TableModel
。
I love that Spring Data JPA handles all the cumbersome implementation of the DAL and was wondering if there's something similar for TableModel
.
基本上,我会有以下几点:
Basically, I would have something along the lines of:
公共类GenericTableModel< T>扩展AbstractTableModel
GenericTableModel
将使用反射和/或注释来查看 T
。
And the GenericTableModel
would use reflection and/or annotations to look into T
.
这样的事情是否存在?我希望我不必为每个想要在JTable上显示的对象都有一个TableModel ..
Does something like this exist? I hope I don't have to have a TableModel for each object I want to display on a JTable..
推荐答案
并且GenericTableModel将使用反射来查看T.
And the GenericTableModel would use reflection to look into T.
Bean Table Model 就是这样做的。
这篇关于我们可以在JTables中使用通用的TableModel吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!