ListSelectionModel model = table.getSelectionModel(); model.clearSelection(); model.addSelectionInterval(1, 1); model.addSelectionInterval(18, 18); model.addSelectionInterval(23, 23);
@Override public void setSelectedIndices(int[] indices) { for (int i : indices) { table.getSelectionModel().addSelectionInterval(i, i); } }
/** * Add the given row index {@code rowIndex} (from the model coordinate) * in the selection of the given table. * * @param table the table where to set the selection * @param rowIndex the row index in the model coordinate to add to selection * @since 2.5.29 */ public static void addRowSelectionInterval(JTable table, int rowIndex) { int rowViewIndex = table.convertRowIndexToView(rowIndex); table.getSelectionModel().addSelectionInterval(rowViewIndex, rowViewIndex); }
public void dataChanged() { int idx = table.getSelectedRow(); tableModel.fireTableDataChanged(); if (idx != -1) { table.getSelectionModel().addSelectionInterval(idx, idx); } }
void dataChanged() { int idx = table.getSelectedRow(); tableModel.fireTableDataChanged(); if (idx != -1) table.getSelectionModel().addSelectionInterval(idx, idx); }
public void addSelectionInterval(final int pIndex0, final int pIndex1) { mListSelectionModel.addSelectionInterval(pIndex0, pIndex1); handleListSelection(); }
public void addSelectionInterval(final int pIndex0, final int pIndex1) { mListSelectionModel.addSelectionInterval(pIndex0, pIndex1); handleListSelection(); }
/** * Add the given row index {@code rowIndex} (from the model coordinate) * in the selection of the given table. * * @param table the table where to set the selection * @param rowIndex the row index in the model coordinate to add to selection * @since 2.5.29 */ public static void addRowSelectionInterval(JTable table, int rowIndex) { int rowViewIndex = table.convertRowIndexToView(rowIndex); table.getSelectionModel().addSelectionInterval(rowViewIndex, rowViewIndex); }
/** * Sets the row-selection for an array of rows. * @param rows the rows */ public void setSelectedRows(int[] rows) { selectionModel.clearSelection(); if (rows != null) { for (int i=0; i < rows.length; i++) { selectionModel.addSelectionInterval(rows[i], rows[i]); } } }
void dataChanged() { int idx = table.getSelectedRow(); tableModel.fireTableDataChanged(); if (idx != -1) table.getSelectionModel().addSelectionInterval(idx, idx); }
@SuppressWarnings("PMD.UnusedFormalParameter") private void selectAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectAllButtonActionPerformed this.mainListSelectionModel.addSelectionInterval(0, this.mainList.getRowCount() - 1); this.mainListModel.fireTableDataChanged(); this.updateRowHeights(); }//GEN-LAST:event_selectAllButtonActionPerformed
private void select(int index){ if(index<0) return; if(sModel.isSelectedIndex(index)) sModel.removeSelectionInterval(index, index); else sModel.addSelectionInterval(index, index); }
public void addSelectionInterval(int index0, int index1) { int uindex0 = constraint.unconstraint(index0); int uindex1 = constraint.unconstraint(index1); delegate.addSelectionInterval(uindex0, uindex1); }
private void toggleSelection(int index){ if(index<0) return; if(selectionModel.isSelectedIndex(index)){ selectionModel.removeSelectionInterval(index, index);} else { selectionModel.addSelectionInterval(index, index);} }
/** * Sets the col-selection for an array of columns. * @param cols the columns */ public void setSelectedColumns(int[] cols) { columnModel.getSelectionModel().clearSelection(); if (cols != null) { for (int i=0; i < cols.length; i++) { columnModel.getSelectionModel().addSelectionInterval(cols[i], cols[i]); } } }
private void doMove(int step) { acceptEditedValue(); ListSelectionModel selectionModel = paramTable.getSelectionModel(); int min = selectionModel.getMinSelectionIndex(); int max = selectionModel.getMaxSelectionIndex(); selectionModel.clearSelection(); model.moveRow(min, max, min + step); selectionModel.addSelectionInterval(min + step, max + step); }
public void setTo(ListSelectionModel sm) { sm.clearSelection(); sm.setSelectionMode(selectionMode); for (int[] itv : intervals) { sm.addSelectionInterval(itv[0], itv[1]); } sm.setAnchorSelectionIndex(anchor); sm.setLeadSelectionIndex(lead); } }
protected void restoreColumnsSelection(ListSelectionModel aSeleted) { // We have to act upon view coordinates here! columnsSelectionModel.clearSelection(); for (int viewColumnIndex = aSeleted.getMinSelectionIndex(); viewColumnIndex <= aSeleted.getMaxSelectionIndex(); viewColumnIndex++) { if (viewColumnIndex >= 0 && viewColumnIndex < columnModel.getColumnCount()) { columnsSelectionModel.addSelectionInterval(viewColumnIndex, viewColumnIndex); } } }
private void setSelectedRowIndices(Collection<Integer> indices) { ListSelectionModel model = getSelectionModel(); model.setValueIsAdjusting(true); model.clearSelection(); for (int index : indices) { model.addSelectionInterval(index, index); } model.setValueIsAdjusting(false); }
public void selectRowsByInstances(Object[] instances, int columnIndex, boolean setVisible) { List instancesList = Arrays.asList(instances); getSelectionModel().clearSelection(); for (int i = 0; i < getRowCount(); i++) { if (instancesList.contains(getValueAt(i, columnIndex))) { getSelectionModel().addSelectionInterval(i, i); } } if (setVisible && (getSelectedRow() != -1)) { ensureRowVisible(getSelectedRow()); } }