< prev index next >

## src/java.desktop/share/classes/javax/swing/JTable.java

Print this page

    2251
    2252     /**
    2253      * Returns the index of the first selected column,
    2254      * -1 if no column is selected.
    2255      * @return the index of the first selected column
    2256      */
    2257     @BeanProperty(bound = false)
    2258     public int getSelectedColumn() {
    2259         return columnModel.getSelectionModel().getMinSelectionIndex();
    2260     }
    2261
    2262     /**
    2263      * Returns the indices of all selected rows.
    2264      *
    2265      * @return an array of integers containing the indices of all selected rows,
    2266      *         or an empty array if no row is selected
    2267      * @see #getSelectedRow
    2268      */
    2269     @BeanProperty(bound = false)
    2270     public int[] getSelectedRows() {
    2271         int iMin = selectionModel.getMinSelectionIndex();
    2272         int iMax = selectionModel.getMaxSelectionIndex();
    2273
    2274         if ((iMin == -1) || (iMax == -1)) {
    2275             return new int[0];
    2276         }
    2277
    2278         int[] rvTmp = new int[1+ (iMax - iMin)];
    2279         int n = 0;
    2280         for(int i = iMin; i <= iMax; i++) {
    2281             if (selectionModel.isSelectedIndex(i)) {
    2282                 rvTmp[n++] = i;
    2283             }
    2284         }
    2285         int[] rv = new int[n];
    2286         System.arraycopy(rvTmp, 0, rv, 0, n);
    2287         return rv;
    2288     }
    2289
    2290     /**
    2291      * Returns the indices of all selected columns.
    2292      *
    2293      * @return an array of integers containing the indices of all selected columns,
    2294      *         or an empty array if no column is selected
    2295      * @see #getSelectedColumn
    2296      */
    2297     @BeanProperty(bound = false)
    2298     public int[] getSelectedColumns() {
    2299         return columnModel.getSelectedColumns();
    2300     }
    2301
    2302     /**
    2303      * Returns the number of selected rows.
    2304      *
    2305      * @return the number of selected rows, 0 if no rows are selected
    2306      */
    2307     @BeanProperty(bound = false)
    2308     public int getSelectedRowCount() {
    2309         int iMin = selectionModel.getMinSelectionIndex();
    2310         int iMax = selectionModel.getMaxSelectionIndex();
    2311         int count = 0;
    2312
    2313         for(int i = iMin; i <= iMax; i++) {
    2314             if (selectionModel.isSelectedIndex(i)) {
    2315                 count++;
    2316             }
    2317         }
    2318         return count;
    2319     }
    2320
    2321     /**
    2322      * Returns the number of selected columns.
    2323      *
    2324      * @return the number of selected columns, 0 if no columns are selected
    2325      */
    2326     @BeanProperty(bound = false)
    2327     public int getSelectedColumnCount() {
    2328         return columnModel.getSelectedColumnCount();
    2329     }
    2330
    2331     /**
    2332      * Returns true if the specified index is in the valid range of rows,
    2333      * and the row at that index is selected.
    2334      *
    2335      * @param row a row in the row model
    2336      * @return true if <code>row</code> is a valid index and the row at
    2337      *              that index is selected (where 0 is the first row)
    2338      */
    2251
    2252     /**
    2253      * Returns the index of the first selected column,
    2254      * -1 if no column is selected.
    2255      * @return the index of the first selected column
    2256      */
    2257     @BeanProperty(bound = false)
    2258     public int getSelectedColumn() {
    2259         return columnModel.getSelectionModel().getMinSelectionIndex();
    2260     }
    2261
    2262     /**
    2263      * Returns the indices of all selected rows.
    2264      *
    2265      * @return an array of integers containing the indices of all selected rows,
    2266      *         or an empty array if no row is selected
    2267      * @see #getSelectedRow
    2268      */
    2269     @BeanProperty(bound = false)
    2270     public int[] getSelectedRows() {
    2271         return selectionModel.getSelectedIndices();

    2272     }
    2273
    2274     /**
    2275      * Returns the indices of all selected columns.
    2276      *
    2277      * @return an array of integers containing the indices of all selected columns,
    2278      *         or an empty array if no column is selected
    2279      * @see #getSelectedColumn
    2280      */
    2281     @BeanProperty(bound = false)
    2282     public int[] getSelectedColumns() {
    2283         return columnModel.getSelectedColumns();
    2284     }
    2285
    2286     /**
    2287      * Returns the number of selected rows.
    2288      *
    2289      * @return the number of selected rows, 0 if no rows are selected
    2290      */
    2291     @BeanProperty(bound = false)
    2292     public int getSelectedRowCount() {
    2293         return selectionModel.getSelectedItemsCount();

    2294     }
    2295
    2296     /**
    2297      * Returns the number of selected columns.
    2298      *
    2299      * @return the number of selected columns, 0 if no columns are selected
    2300      */
    2301     @BeanProperty(bound = false)
    2302     public int getSelectedColumnCount() {
    2303         return columnModel.getSelectedColumnCount();
    2304     }
    2305
    2306     /**
    2307      * Returns true if the specified index is in the valid range of rows,
    2308      * and the row at that index is selected.
    2309      *
    2310      * @param row a row in the row model
    2311      * @return true if <code>row</code> is a valid index and the row at
    2312      *              that index is selected (where 0 is the first row)
    2313      */

< prev index next >