2016-09-17 19 views
1

我在想什麼最好的方法是讓JTable中一次只能選擇一行?有沒有一種方法來設置,我已經錯過了或者我需要重寫它是一種方式?如何在JTable中一次只選中一行?

我使用的是Oracle JDK 8

+1

沒有ü嘗試:的setSelectionMode(ListSelectionModel.SINGLE_SELECTION)? – chenchuk

+0

http://docs.oracle.com/javase/tutorial/uiswing/components/table.html –

回答

2

您需要:

table.setRowSelectionAllowed(true); 
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 
相關問題