JTable列跨越 [英] JTable column spanning

查看:193
本文介绍了JTable列跨越的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个具有列跨度的 JTable 。具体来说,我希望在另一个 JTable 中嵌套一个 JTable ,当用户点击查看嵌套表时,它应该展开以按下下面的行并填充空白区域。这与您在MS Access中可以嵌套表格的内容类似,单击行上的展开按钮将显示嵌套表格中的相应条目。

I am trying to make a JTable that has column spans available. Specifically, I am looking to nest a JTable inside another JTable, and when the user clicks to view the nested table, it should expand to push down the rows below and fill the empty space. This is similar to what you see in MS Access where you can nest tables, and clicking the expand button on a row will show you the corresponding entries in the nested table.

如果有人知道用 JTable 执行列跨度的方法,请指点我在右边方向?或者,如果您知道另一种方法,我愿意接受建议。该应用程序正在使用Swing构建。表中的元素,无论是高级还是低级,都必须在任何解决方案中都可编辑。使用嵌套的 JTable 这不会有问题,任何其他解决方案也必须考虑到这一点。

If someone knows of a way to perform a column span with JTable, can you please point me in the right direction? Or if you know of an alternative way to do this, I am open to suggestions. The application is being built with Swing. Elements in the table, both high level and low level, have to be editable in any solution. Using nested JTables this won't be a problem, and any other solution would have to take this into consideration as well.

推荐答案

作为指向正确方向的指针,请尝试 this SwingWiki上的文章解释了列的跨越的TableUI方法。在此之前,我还尝试了一些替代方法,例如重写TableCellRenderer绘制方法,但没有取得多大成功。

As a pointer in the right direction, try this article at SwingWiki that explains the TableUI method of column spanning quite well. Before this, I also tried some alternatives such as overriding the TableCellRenderer paint methods without much success.

这篇关于JTable列跨越的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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