Java Code Examples for javax.swing.ListSelectionModel#removeSelectionInterval()

The following examples show how to use javax.swing.ListSelectionModel#removeSelectionInterval() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwingUtilities2.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Set the lead and anchor without affecting selection.
 */
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);
    }
}
 
Example 2
Source File: AnySelectionTable.java    From wandora with GNU General Public License v3.0 6 votes vote down vote up
public void invertSelection() {
    if(tableSelectionModel != null) {
        int colCount = this.getColumnCount();
        int rowCount = this.getRowCount();
        for(int c=0; c<colCount; c++) {
            ListSelectionModel columnSelectionModel = tableSelectionModel.getListSelectionModelAt(c);
            if(columnSelectionModel != null) {
                for(int r=0; r<rowCount; r++) {
                    if(columnSelectionModel.isSelectedIndex(r)) {
                        columnSelectionModel.removeSelectionInterval(r, r);
                    }
                    else {
                        columnSelectionModel.addSelectionInterval(r, r);
                    }
                }
            }
        }
    }
    this.repaint();
}
 
Example 3
Source File: TranslateGroupManuallyPopup.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public static void reSelect(final ListSelectionModel lsm)
{
	final int maxSelectionIndex = lsm.getMaxSelectionIndex();
	for (int i = 0; i <= maxSelectionIndex; i++)
		if (lsm.isSelectedIndex( i ))
		{
			lsm.removeSelectionInterval( i, i );
			lsm.addSelectionInterval( i, i );
		}
}
 
Example 4
Source File: AnySelectionTable.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
public void deselectColumn(int column) {
    int rowCount = this.getRowCount();
    int colCount = this.getColumnCount();
    if(tableSelectionModel != null && column < colCount) {
        ListSelectionModel columnSelectionModel = tableSelectionModel.getListSelectionModelAt(column);
        if(columnSelectionModel != null) {
            columnSelectionModel.removeSelectionInterval(0, rowCount-1);
        }
    }
    this.repaint();
}
 
Example 5
Source File: AnySelectionTable.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
public void deselectRow(int row) {
    int colCount = this.getColumnCount();
    int rowCount = this.getRowCount();
    if(tableSelectionModel != null && row < rowCount) {
        ListSelectionModel columnSelectionModel = null;
        for(int c=0; c<colCount; c++) {
            columnSelectionModel = tableSelectionModel.getListSelectionModelAt(c);
            if(columnSelectionModel != null) {
                columnSelectionModel.removeSelectionInterval(row, row);
            }
        }
    }
    this.repaint();
}
 
Example 6
Source File: TableSelectionModel.java    From wandora with GNU General Public License v3.0 4 votes vote down vote up
/**
* Forwards the request to the ListSelectionModel
* at the specified column.
*/
public void removeSelection(int row, int column) {
    ListSelectionModel lsm = getListSelectionModelAt(column);
    lsm.removeSelectionInterval(row, row);
}