禁用JTable的特定行 [英] Disable particular rows of a JTable
本文介绍了禁用JTable的特定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想灰显" JTable的特定行,以免任何方式选择它们.其他行仍然应该是可选的.我该怎么做?
I would like to "grey out" particular rows of a JTable so that they may not be selected by any means. The other rows should still be selectable. How do I accomplish this?
推荐答案
您可以覆盖JTable.changeSelection()
以在选定时取消选择有问题的行,或者为您的表提供自定义的ListSelectionModel
,您可以在其中覆盖setSelectionInterval()
, addSelectionInterval()
等,以防止首先选择该行.
You can either override JTable.changeSelection()
to deselect the offending row whenever it's selected, or provide your table with a custom ListSelectionModel
where you override setSelectionInterval()
, addSelectionInterval()
, etc. to prevent the row from being selected in the first place.
这篇关于禁用JTable的特定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文