简体   繁体   English

禁用对JTable的特定行的选择

[英]Disable Selection of Particular rows on a JTable

I am currently using setRowSelectionAllowed(boolean) method. 我目前正在使用setRowSelectionAllowed(boolean)方法。 In my implementation, it disables all the rows. 在我的实现中,它禁用所有行。 However what I want is to to disable some rows and not all the rows. 但是我想要禁用某些行而不是所有行。 Can someone please help me that to accomplish this? 有人可以帮我做到这一点吗?

Here is my code 这是我的代码

if (encounterId == currentencounterId)
{                                      
  getNstTemplates().getTable().setRowSelectionAllowed(true);                    
}                           
else                        
{   
  getNstTemplates().getTable().setRowSelectionAllowed(false);                                 
}

您可以将自定义ListSelectionModel插入表中,该表将忽略或修改涉及不可选择行的选择事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM