本文整理汇总了Java中javax.swing.ListSelectionModel.setSelectionInterval方法的典型用法代码示例。如果您正苦于以下问题:Java ListSelectionModel.setSelectionInterval方法的具体用法?Java ListSelectionModel.setSelectionInterval怎么用?Java ListSelectionModel.setSelectionInterval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.ListSelectionModel
的用法示例。
在下文中一共展示了ListSelectionModel.setSelectionInterval方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showNextSelection
import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
void showNextSelection(boolean forward) {
int selectedRow = this.getSelectedRow();
int lastRowIndex = this.getRowCount() - 1;
ListSelectionModel selection = this.getSelectionModel();
int toSelect;
if (forward) {
toSelect = selectedRow + 1;
} else {
toSelect = selectedRow - 1;
}
if (toSelect < 0) {
toSelect = lastRowIndex;
} else if (toSelect > lastRowIndex) {
toSelect = 0;
}
selection.setSelectionInterval(toSelect, toSelect);
}
示例2: onUpClick
import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
private void onUpClick() {
ListSelectionModel listSelectionModel = getSelectionModel();
int r = listSelectionModel.getMinSelectionIndex();
if(r > 0) {
DefaultTableModel model = getModel();
int rNew = r - 1;
model.moveRow(r, r, rNew) ;
listSelectionModel.setSelectionInterval(rNew, rNew);
}
}
示例3: onDownClick
import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
private void onDownClick() {
ListSelectionModel listSelectionModel = getSelectionModel();
int r = listSelectionModel.getMinSelectionIndex();
DefaultTableModel model = getModel();
if(r > -1 && r < model.getRowCount() - 1) {
int rNew = r + 1;
model.moveRow(r, r, rNew) ;
listSelectionModel.setSelectionInterval(rNew, rNew);
}
}
示例4: onRemoveClick
import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
private void onRemoveClick() {
ListSelectionModel selectionModel = getSelectionModel();
int r = selectionModel.getMinSelectionIndex();
if(r > -1) {
getModel().removeRow(r);
}
int size = getModel().getRowCount();
if(size > 0) {
if (r > size - 1) {
r = size - 1;
}
selectionModel.setSelectionInterval(r, r);
}
}