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


Java DefaultListSelectionModel.getMaxSelectionIndex方法代碼示例

本文整理匯總了Java中javax.swing.DefaultListSelectionModel.getMaxSelectionIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultListSelectionModel.getMaxSelectionIndex方法的具體用法?Java DefaultListSelectionModel.getMaxSelectionIndex怎麽用?Java DefaultListSelectionModel.getMaxSelectionIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.DefaultListSelectionModel的用法示例。


在下文中一共展示了DefaultListSelectionModel.getMaxSelectionIndex方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: valueChanged

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
@Override
public void valueChanged(ListSelectionEvent e) {
	DefaultListSelectionModel selectionModel = (DefaultListSelectionModel) e.getSource();
	int count = selectionModel.getMaxSelectionIndex() - selectionModel.getMinSelectionIndex() + 1;
	if (count > 1) {
		btEdit.setEnabled(false);
		btCopy.setEnabled(false);
		btDelete.setEnabled(allowMultiDelete);
		if (hasOrder) {
			btOrderUp.setEnabled(false);
			btOrderDown.setEnabled(false);
		}
		return;
	}
	int row = selectionModel.getMinSelectionIndex();
	AbstractEntity entity = getEntityFromRow(row);
	boolean b=true;
	if (entity == null) b=false;
	btEdit.setEnabled(b);
	btCopy.setEnabled(b);
	btDelete.setEnabled(b);
	if (hasOrder) {
		btOrderUp.setEnabled(b);
		btOrderDown.setEnabled(b);
	}
}
 
開發者ID:markkohdev,項目名稱:oStorybook,代碼行數:27,代碼來源:AbstractTable.java

示例2: insureRowContinuity

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
/**
 * Makes sure the currently selected <code>TreePath</code>s are valid
 * for the current selection mode.
 * If the selection mode is <code>CONTIGUOUS_TREE_SELECTION</code>
 * and a <code>RowMapper</code> exists, this will make sure all
 * the rows are contiguous, that is, when sorted all the rows are
 * in order with no gaps.
 * If the selection isn't contiguous, the selection is
 * reset to contain the first set, when sorted, of contiguous rows.
 * <p>
 * If the selection mode is <code>SINGLE_TREE_SELECTION</code> and
 * more than one TreePath is selected, the selection is reset to
 * contain the first path currently selected.
 */
protected void insureRowContinuity() {
    if(selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION &&
       selection != null && rowMapper != null) {
        DefaultListSelectionModel lModel = listSelectionModel;
        int                       min = lModel.getMinSelectionIndex();

        if(min != -1) {
            for(int counter = min,
                    maxCounter = lModel.getMaxSelectionIndex();
                    counter <= maxCounter; counter++) {
                if(!lModel.isSelectedIndex(counter)) {
                    if(counter == min) {
                        clearSelection();
                    }
                    else {
                        TreePath[] newSel = new TreePath[counter - min];
                        int selectionIndex[] = rowMapper.getRowsForPaths(selection);
                        // find the actual selection pathes corresponded to the
                        // rows of the new selection
                        for (int i = 0; i < selectionIndex.length; i++) {
                            if (selectionIndex[i]<counter) {
                                newSel[selectionIndex[i]-min] = selection[i];
                            }
                        }
                        setSelectionPaths(newSel);
                        break;
                    }
                }
            }
        }
    }
    else if(selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION &&
            selection != null && selection.length > 1) {
        setSelectionPath(selection[0]);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:51,代碼來源:DefaultTreeSelectionModel.java

示例3: insureRowContinuity

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
protected void insureRowContinuity() {
	if (selectionMode == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION
			&& selection != null && rowMapper != null) {
		DefaultListSelectionModel lModel = listSelectionModel;
		int min = lModel.getMinSelectionIndex();

		if (min != -1) {
			for (int counter = min, maxCounter = lModel
					.getMaxSelectionIndex(); counter <= maxCounter; counter++) {
				if (!lModel.isSelectedIndex(counter)) {
					if (counter == min) {
						clearSelection();
					} else {
						TreePath[] newSel = new TreePath[counter - min];
						int selectionIndex[] = rowMapper.getRowsForPaths(selection);
						for (int i = 0; i < selectionIndex.length; i++) {
							if (selectionIndex[i] < counter) {
								newSel[selectionIndex[i] - min] = selection[i];
							}
						}
						setSelectionPaths(newSel);
						break;
					}
				}
			}
		}
	} else if (selectionMode == TreeSelectionModel.SINGLE_TREE_SELECTION
			&& selection != null && selection.length > 1) {
		setSelectionPath(selection[0]);
	}
}
 
開發者ID:javalovercn,項目名稱:j2se_for_android,代碼行數:32,代碼來源:DefaultTreeSelectionModel.java

示例4: testInsertBeforeSelectedSM

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
/**
 * Issue #272-swingx: inserted row is selected.
 * Not a bug: documented behaviour of DefaultListSelectionModel.
 */
public void testInsertBeforeSelectedSM() {
    DefaultListSelectionModel model = new DefaultListSelectionModel();
    model.setSelectionInterval(3, 3);
    model.insertIndexInterval(3, 1, true);
    int max = model.getMaxSelectionIndex();
    int min = model.getMinSelectionIndex();
    assertEquals(max, min);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:13,代碼來源:JTableIssues.java

示例5: mouseClicked

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
@Override
public void mouseClicked(MouseEvent e) {
	DefaultListSelectionModel selectionModel = (DefaultListSelectionModel) table.getSelectionModel();
	if (e.getClickCount() == 2) {
		int count = selectionModel.getMaxSelectionIndex() - selectionModel.getMinSelectionIndex() + 1;
		if (count > 1) {
			return;
		}
		int row = selectionModel.getMinSelectionIndex();
		sendSetEntityToEdit(row);
	} else {
		BookController ctrl = mainFrame.getBookController();
		ctrl.showInfo(getEntityFromRow(selectionModel.getMinSelectionIndex()));
	}
}
 
開發者ID:markkohdev,項目名稱:oStorybook,代碼行數:16,代碼來源:AbstractTable.java

示例6: canPathsBeAdded

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
/**
 * Used to test if a particular set of <code>TreePath</code>s can
 * be added. This will return true if <code>paths</code> is null (or
 * empty), or this object has no RowMapper, or nothing is currently selected,
 * or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
 * adding the paths to the current selection still results in a
 * contiguous set of <code>TreePath</code>s.
 */
protected boolean canPathsBeAdded(TreePath[] paths) {
    if(paths == null || paths.length == 0 || rowMapper == null ||
       selection == null || selectionMode ==
       TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
        return true;
    else {
        BitSet                       bitSet = new BitSet();
        DefaultListSelectionModel    lModel = listSelectionModel;
        int                          anIndex;
        int                          counter;
        int                          min = lModel.getMinSelectionIndex();
        int                          max = lModel.getMaxSelectionIndex();
        TreePath[]                   tempPath = new TreePath[1];

        if(min != -1) {
            for(counter = min; counter <= max; counter++) {
                if(lModel.isSelectedIndex(counter))
                    bitSet.set(counter);
            }
        }
        else {
            tempPath[0] = paths[0];
            min = max = rowMapper.getRowsForPaths(tempPath)[0];
        }
        for(counter = paths.length - 1; counter >= 0; counter--) {
            if(paths[counter] != null) {
                tempPath[0] = paths[counter];
                int[]   rows = rowMapper.getRowsForPaths(tempPath);
                if (rows == null) {
                    return false;
                }
                anIndex = rows[0];
                min = Math.min(anIndex, min);
                max = Math.max(anIndex, max);
                if(anIndex == -1)
                    return false;
                bitSet.set(anIndex);
            }
        }
        for(counter = min; counter <= max; counter++)
            if(!bitSet.get(counter))
                return false;
    }
    return true;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:54,代碼來源:DefaultTreeSelectionModel.java

示例7: canPathsBeAdded

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
/**
 * Used to test if a particular set of <code>TreePath</code>s can
 * be added. This will return true if <code>paths</code> is null (or
 * empty), or this object has no RowMapper, or nothing is currently selected,
 * or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
 * adding the paths to the current selection still results in a
 * contiguous set of <code>TreePath</code>s.
 *
 * @param paths array of {@code TreePaths} to check
 * @return      whether the particular set of {@code TreePaths} can be added
 */
protected boolean canPathsBeAdded(TreePath[] paths) {
    if(paths == null || paths.length == 0 || rowMapper == null ||
       selection == null || selectionMode ==
       TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
        return true;
    else {
        BitSet                       bitSet = new BitSet();
        DefaultListSelectionModel    lModel = listSelectionModel;
        int                          anIndex;
        int                          counter;
        int                          min = lModel.getMinSelectionIndex();
        int                          max = lModel.getMaxSelectionIndex();
        TreePath[]                   tempPath = new TreePath[1];

        if(min != -1) {
            for(counter = min; counter <= max; counter++) {
                if(lModel.isSelectedIndex(counter))
                    bitSet.set(counter);
            }
        }
        else {
            tempPath[0] = paths[0];
            min = max = rowMapper.getRowsForPaths(tempPath)[0];
        }
        for(counter = paths.length - 1; counter >= 0; counter--) {
            if(paths[counter] != null) {
                tempPath[0] = paths[counter];
                int[]   rows = rowMapper.getRowsForPaths(tempPath);
                if (rows == null) {
                    return false;
                }
                anIndex = rows[0];
                min = Math.min(anIndex, min);
                max = Math.max(anIndex, max);
                if(anIndex == -1)
                    return false;
                bitSet.set(anIndex);
            }
        }
        for(counter = min; counter <= max; counter++)
            if(!bitSet.get(counter))
                return false;
    }
    return true;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:57,代碼來源:DefaultTreeSelectionModel.java

示例8: canPathsBeAdded

import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
protected boolean canPathsBeAdded(TreePath[] paths) {
	if (paths == null
			|| paths.length == 0
			|| rowMapper == null
			|| selection == null
			|| selectionMode == TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
		return true;
	else {
		BitSet bitSet = new BitSet();
		DefaultListSelectionModel lModel = listSelectionModel;
		int anIndex;
		int counter;
		int min = lModel.getMinSelectionIndex();
		int max = lModel.getMaxSelectionIndex();
		TreePath[] tempPath = new TreePath[1];

		if (min != -1) {
			for (counter = min; counter <= max; counter++) {
				if (lModel.isSelectedIndex(counter))
					bitSet.set(counter);
			}
		} else {
			tempPath[0] = paths[0];
			min = max = rowMapper.getRowsForPaths(tempPath)[0];
		}
		for (counter = paths.length - 1; counter >= 0; counter--) {
			if (paths[counter] != null) {
				tempPath[0] = paths[counter];
				int[] rows = rowMapper.getRowsForPaths(tempPath);
				if (rows == null) {
					return false;
				}
				anIndex = rows[0];
				min = Math.min(anIndex, min);
				max = Math.max(anIndex, max);
				if (anIndex == -1)
					return false;
				bitSet.set(anIndex);
			}
		}
		for (counter = min; counter <= max; counter++)
			if (!bitSet.get(counter))
				return false;
	}
	return true;
}
 
開發者ID:javalovercn,項目名稱:j2se_for_android,代碼行數:47,代碼來源:DefaultTreeSelectionModel.java


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