开发者

How to make a JTable row to an "unselected" state after selected any row in that table?

开发者 https://www.devze.com 2023-04-09 13:17 出处:网络
I\'m developing a Java Swing application which contains a JTable. By default, while launchin开发者_运维问答g the application for the first time, the call to the method jtable.getSelectedRow() or jtabl

I'm developing a Java Swing application which contains a JTable. By default, while launchin开发者_运维问答g the application for the first time, the call to the method jtable.getSelectedRow() or jtable.getSelectedColumn() returns -1, which means that no row selected at that moment. After user clicked any row or column, the call to the method jtable.getSelectedRow() or jtable.getSelectedColumn() returns the appropriate values of selected rows & columns. What I actually need is that I want to set the selected row or column to -1 i.e. "no row or column selected state". How can I do this?


The JTable method clearSelection will do what you want -- clear the selection of all the table's selected rows and columns. The JTable API is the place to look for methods such as these.

0

精彩评论

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