当前位置: 首页>>代码示例>>Java>>正文


Java ListSelectionModel.getMinSelectionIndex方法代码示例

本文整理汇总了Java中javax.swing.ListSelectionModel.getMinSelectionIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ListSelectionModel.getMinSelectionIndex方法的具体用法?Java ListSelectionModel.getMinSelectionIndex怎么用?Java ListSelectionModel.getMinSelectionIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.ListSelectionModel的用法示例。


在下文中一共展示了ListSelectionModel.getMinSelectionIndex方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onEditClick

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
private void onEditClick() {
    ListSelectionModel selectionModel = getSelectionModel();
    int r = selectionModel.getMinSelectionIndex();        
    if(r < 0) return;

    String pattern = (String) getModel().getValueAt(r, 0);
    String folder  = (String) getModel().getValueAt(r, 1);      

    EditAnnotationPanel editPanel = new EditAnnotationPanel();
    if(pattern != null) editPanel.patternTextField.setText(pattern);
    if(folder  != null) editPanel.folderTextField.setText(folder);
    
    String title = NbBundle.getMessage(AnnotationSettings.class, "AnnotationSettings.edit.title");        
    if(showEdit(editPanel, title)) {
        getModel().setValueAt(editPanel.patternTextField.getText(), r, 0);
        getModel().setValueAt(editPanel.folderTextField.getText(),  r, 1);                        
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:AnnotationSettings.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

示例4: canEdit

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
public static boolean canEdit( ListSelectionModel selectionModel, DefaultListModel listModel ) {        
    boolean can =  selectionModel.getMinSelectionIndex() == selectionModel.getMaxSelectionIndex() 
                      && selectionModel.getMinSelectionIndex() != -1;
    if (can) {
        ClassPathSupport.Item item = (ClassPathSupport.Item) listModel.get(selectionModel.getMinSelectionIndex());
        can = item != null && item.canEdit();
    }
    return can;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ClassPathUiSupport.java

示例5: 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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:AnnotationSettings.java

示例6: 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);
    }        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:AnnotationSettings.java

示例7: 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);    
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:AnnotationSettings.java

示例8: valueChanged

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
public void valueChanged(ListSelectionEvent evt) {
    ListSelectionModel selectionModel = getSelectionModel();
    int r = selectionModel.getMinSelectionIndex();        
    panel.upButton.setEnabled(r > 0);
    panel.downButton.setEnabled(r > -1 && r < getModel().getRowCount() - 1);            
    panel.removeButton.setEnabled(r > -1);                    
    panel.editButton.setEnabled(r > -1);                    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:AnnotationSettings.java

示例9: valueChanged

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void valueChanged (ListSelectionEvent e) {
    if (e.getValueIsAdjusting()) {
        return;
    }
    List<VCSStatusNode> selectedNodes = new ArrayList<VCSStatusNode>();
    ListSelectionModel selection = table.getSelectionModel();
    final TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, table);
    int min = selection.getMinSelectionIndex();
    if (min != -1) {
        int max = selection.getMaxSelectionIndex();
        for (int i = min; i <= max; i++) {
            if (selection.isSelectedIndex(i)) {
                int idx = table.convertRowIndexToModel(i);
                selectedNodes.add(tableModel.getNode(idx));
            }
        }
    }
    final T[] nodeArray = selectedNodes.toArray((T[]) java.lang.reflect.Array.newInstance(tableModel.getItemClass(), selectedNodes.size()));
    Mutex.EVENT.readAccess(new Runnable() {
        @Override
        public void run() {
            File[] selectedFiles = new File[nodeArray.length];
            for (int i = 0; i < nodeArray.length; ++i) {
                selectedFiles[i] = nodeArray[i].getFile();
            }
            support.firePropertyChange(PROP_SELECTED_FILES, null, selectedFiles);
            if (tc != null) {
                tc.setActivatedNodes(nodeArray);
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:VCSStatusTable.java

示例10: getSelectedIndices

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
private int[] getSelectedIndices() {
    ListSelectionModel mdl = listClasses.getSelectionModel();
    int min = mdl.getMinSelectionIndex();
    int max = mdl.getMaxSelectionIndex();
    int[] indices = new int[max - min + 1];
    int ix = 0;
    for (int i = mdl.getMinSelectionIndex(); i <= max; i++) {
        if (mdl.isSelectedIndex(i)) {
            indices[ix++] = i;
        }
    }
    int[] result = new int[ix];
    System.arraycopy(indices, 0, result, 0, ix);
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:ClassNameList.java

示例11: copyCellDown

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
/**
 * Copies the value of the anchor (focused) down to the end of its column
 */
void copyCellDown() {
	stopEditing();
	int anchorRow = selectionModel.getAnchorSelectionIndex();
	ListSelectionModel csm = columnModel.getSelectionModel();
	int colFrom = csm.getMinSelectionIndex();
	int colTo = csm.getMaxSelectionIndex();
	LDTableModel dm = (LDTableModel) dataModel;

	for (int i = colFrom; i <= colTo; i++) {
		dm.copyCellDown(anchorRow, i);
	}
	updateRows(anchorRow + 1, getRowCount());
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:17,代码来源:LDEditingWindow.java

示例12: fillCells

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
/**
 * Fills in selected cells with values obtained evaluating <code>expr</code>
 * @throws jmt.common.exception.ExpressionParseException if there were errors parsing expr
 */
void fillCells(String expr) throws ExpressionParseException {
	stopEditing();
	int rowFrom = selectionModel.getMinSelectionIndex();
	int rowTo = selectionModel.getMaxSelectionIndex();
	ListSelectionModel csm = columnModel.getSelectionModel();
	int colFrom = csm.getMinSelectionIndex();
	int colTo = csm.getMaxSelectionIndex();

	((LDTableModel) dataModel).fillCells(expr, rowFrom, rowTo, colFrom, colTo);

}
 
开发者ID:max6cn,项目名称:jmt,代码行数:16,代码来源:LDEditingWindow.java

示例13: valueChanged

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
/**
 * When a key is selected in the table, display the source and translated
 * texts in the right hand panels
 */
public void valueChanged(ListSelectionEvent e) {
  if (e.getValueIsAdjusting())
    return;

  ListSelectionModel lsm = (ListSelectionModel) e.getSource();
  if (lsm.isSelectionEmpty()) {
    return;
  }
  else {
    String key = keys[lsm.getMinSelectionIndex()];
    currentKey = keyTarget.getI18nData().getFullPrefix() + key; //$NON-NLS-1$
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:18,代码来源:TranslateWindow.java

示例14: canMoveUp

import javax.swing.ListSelectionModel; //导入方法依赖的package包/类
public static boolean canMoveUp( ListSelectionModel selectionModel ) {        
    return selectionModel.getMinSelectionIndex() > 0;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:ClassPathUiSupport.java


注:本文中的javax.swing.ListSelectionModel.getMinSelectionIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。