开发者

JTable using binding, how to get selected Element?

I'm using binding machanism to show data from database table in 开发者_高级运维jTable. I've had problem with adding new Element and refreshing jTable, but finally I solved it (observable property in List). Now I want to get Element from jTable, change it (setters) and save changes (flush?). How can I achieve it?

Thanks in advance!


OK, solved.

Element elem = (Element) list.get(jTable.convertRowIndexToModel(jTable.getSelectedRow()));

where:
Element - entity class
list - entityManager.createQuery("SELECT e FROM Element e").getResultList();

Make sure list is observable (to see changes in jTable immidiately).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜