Example usage for javax.swing ListSelectionModel removeSelectionInterval

List of usage examples for javax.swing ListSelectionModel removeSelectionInterval

Introduction

In this page you can find the example usage for javax.swing ListSelectionModel removeSelectionInterval.

Prototype

void removeSelectionInterval(int index0, int index1);

Source Link

Document

Changes the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive.

Usage

From source file:Main.java

/**
 * Set the lead and anchor without affecting selection.
 *//*from ww w . j  av a 2s.com*/
public static void setLeadAnchorWithoutSelection(ListSelectionModel model, int lead, int anchor) {
    if (anchor == -1) {
        anchor = lead;
    }
    if (lead == -1) {
        model.setAnchorSelectionIndex(-1);
        model.setLeadSelectionIndex(-1);
    } else {
        if (model.isSelectedIndex(lead)) {
            model.addSelectionInterval(lead, lead);
        } else {
            model.removeSelectionInterval(lead, lead);
        }
        model.setAnchorSelectionIndex(anchor);
    }
}

From source file:org.processmining.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Inverts the current selection status of the table containing the process
 * instances. This means that instances that have been selected will result
 * being unselected and the other way round.
 *///from   ww w .j  a va2 s . co  m
private void invertSelectionStatus() {
    ListSelectionModel selectionModel = processInstanceIDsTable.getSelectionModel();
    // step through the table
    for (int index = 0; index < extendedLog.getSizeOfLog(); index++) {
        if (selectionModel.isSelectedIndex(index) == true) {
            // if entry is currently selected --> deselect
            selectionModel.removeSelectionInterval(index, index);
        } else {
            // if entry is currently not selected --> select
            selectionModel.addSelectionInterval(index, index);
        }
    }
    hideAllMetrics();
    updateResults();
}