简体   繁体   中英

How to only allow one row at a time to be selected in a JTable?

I was wondering what the best way is to make it so that only one row at a time can be selected in a JTable? Is there a method to set this which I have missed or do I need to override it is some way?

I am using Oracle JDK 8.

You need to:

table.setRowSelectionAllowed(true);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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