java JTable中的选择模式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2407136/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 21:00:21  来源:igfitidea点击:

Selection mode in JTable?

javaselectionmodel

提问by Venkat

I couldn't understand the difference between multiple_selection_intervaland single_interval_selectionin JTable.

我无法理解multiple_selection_intervalsingle_interval_selectionin之间的区别JTable

table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

next, is

接下来,是

table.setSelectionMode(ListSelectionModel.MULTIPLE_SELECTION_INTERVAL);

What's the difference these?

这些有什么区别?

回答by Georg Leber

With ListSelectionModel.SINGLE_SELECTIONyou can just select one row. With ListSelectionModel.SINGLE_INTERVAL_SELECTIONyou can select more than one row, which are in one block. (e.g. you can select row 1 - 5, but not row 1-3 and row 4-6, therefor you need ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)

有了ListSelectionModel.SINGLE_SELECTION你可以选择一行。随着ListSelectionModel.SINGLE_INTERVAL_SELECTION您可以选择多行,这是在一个街区。(例如,您可以选择第 1-5 行,但不能选择第 1-3 行和第 4-6 行,因此您需要ListSelectionModel.MULTIPLE_INTERVAL_SELECTION