本文整理汇总了Java中javax.swing.ListSelectionModel.getAnchorSelectionIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ListSelectionModel.getAnchorSelectionIndex方法的具体用法?Java ListSelectionModel.getAnchorSelectionIndex怎么用?Java ListSelectionModel.getAnchorSelectionIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.ListSelectionModel
的用法示例。
在下文中一共展示了ListSelectionModel.getAnchorSelectionIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Selection
import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
public Selection(ListSelectionModel sm) {
selectionMode = sm.getSelectionMode();
anchor = sm.getAnchorSelectionIndex();
lead = sm.getLeadSelectionIndex();
int min = sm.getMinSelectionIndex();
int max = sm.getMaxSelectionIndex();
int i1 = -1;
for (int i = min; i <= max; i++) {
if (sm.isSelectedIndex(i)) {
if (i1 == -1) {
i1 = i;
}
} else {
if (i1 != -1) {
intervals.add(new int[] { i1, i});
i1 = -1;
}
}
}
if (i1 != -1) {
intervals.add(new int[] { i1, max});
}
}
示例2: getSelectedRowsInModel
import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
/**
* Convert indices of selected rows to model.
*/
private SelectedRows getSelectedRowsInModel() {
SelectedRows sr = new SelectedRows();
int rows[] = getSelectedRows();
sr.rowsInView = rows;
int[] modelRows = new int[rows.length];
for (int i = 0; i < rows.length; i++) {
modelRows[i] = convertRowIndexToModel(rows[i]);
}
//System.err.println("getSelectedRowsInModel() sets new rows from view: "+
// Arrays.toString(rows)+" to model rows: "+Arrays.toString(modelRows));
sr.rowsInModel = modelRows;
ListSelectionModel rsm = getSelectionModel();
sr.anchorInView = rsm.getAnchorSelectionIndex();
sr.leadInView = rsm.getLeadSelectionIndex();
int rc = getRowCount();
sr.anchorInModel = (sr.anchorInView < rc) ? convertRowIndexToModel(sr.anchorInView) : -1;
sr.leadInModel = (sr.leadInView < rc) ? convertRowIndexToModel(sr.leadInView) : -1;
return sr;
}
示例3: copyAnchorToSelection
import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
public void copyAnchorToSelection() {
if ((getSelectedRowCount() == 0) && (getSelectedColumnCount() == 0)) {
return;
}
if (dataModel instanceof ExactTableModel) {
stopEditing();
int rowFrom = selectionModel.getMinSelectionIndex();
int rowTo = selectionModel.getMaxSelectionIndex();
ListSelectionModel csm = columnModel.getSelectionModel();
int colFrom = csm.getMinSelectionIndex();
int colTo = csm.getMaxSelectionIndex();
int anchorRow = selectionModel.getAnchorSelectionIndex();
int anchorCol = csm.getAnchorSelectionIndex();
((ExactTableModel) dataModel).copyCellToArea(anchorRow, anchorCol, rowFrom, rowTo, colFrom, colTo);
updateRows(rowFrom, rowTo);
requestFocus();
}
}