e940. enabling single or multiple selections in a jtable component.txt
来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 19 行
TXT
19 行
By default, a table component allows multiple selections. To control the selection behavior, see e939 Enabling Row, Column, or Cell Selections in a JTable Component.
JTable table = new JTable();
// Get default selection mode
int selMode = table.getSelectionModel().getSelectionMode();
// MULTIPLE_INTERVAL_SELECTION
// Allow only single a selection
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// Allow selection to span one contiguous set of rows,
// visible columns, or block of cells
table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
// Allow multiple selections of rows, visible columns, or cell blocks (default)
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?