當前位置: 首頁>>代碼示例>>Java>>正文


Java ListSelectionModel.getAnchorSelectionIndex方法代碼示例

本文整理匯總了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});
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:OutlineView.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:ETable.java

示例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();
	}
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:21,代碼來源:ExactTable.java


注:本文中的javax.swing.ListSelectionModel.getAnchorSelectionIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。