< prev index next >
src/java.desktop/share/classes/javax/swing/JTable.java
Print this page
*** 2266,2292 ****
* or an empty array if no row is selected
* @see #getSelectedRow
*/
@BeanProperty(bound = false)
public int[] getSelectedRows() {
! int iMin = selectionModel.getMinSelectionIndex();
! int iMax = selectionModel.getMaxSelectionIndex();
!
! if ((iMin == -1) || (iMax == -1)) {
! return new int[0];
! }
!
! int[] rvTmp = new int[1+ (iMax - iMin)];
! int n = 0;
! for(int i = iMin; i <= iMax; i++) {
! if (selectionModel.isSelectedIndex(i)) {
! rvTmp[n++] = i;
! }
! }
! int[] rv = new int[n];
! System.arraycopy(rvTmp, 0, rv, 0, n);
! return rv;
}
/**
* Returns the indices of all selected columns.
*
--- 2266,2276 ----
* or an empty array if no row is selected
* @see #getSelectedRow
*/
@BeanProperty(bound = false)
public int[] getSelectedRows() {
! return selectionModel.getSelectedIndices();
}
/**
* Returns the indices of all selected columns.
*
*** 2304,2323 ****
*
* @return the number of selected rows, 0 if no rows are selected
*/
@BeanProperty(bound = false)
public int getSelectedRowCount() {
! int iMin = selectionModel.getMinSelectionIndex();
! int iMax = selectionModel.getMaxSelectionIndex();
! int count = 0;
!
! for(int i = iMin; i <= iMax; i++) {
! if (selectionModel.isSelectedIndex(i)) {
! count++;
! }
! }
! return count;
}
/**
* Returns the number of selected columns.
*
--- 2288,2298 ----
*
* @return the number of selected rows, 0 if no rows are selected
*/
@BeanProperty(bound = false)
public int getSelectedRowCount() {
! return selectionModel.getSelectedItemsCount();
}
/**
* Returns the number of selected columns.
*
< prev index next >