本文整理匯總了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();
}
}