当前位置: 首页>>代码示例>>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;未经允许,请勿转载。