< prev index next >

modules/controls/src/main/java/javafx/scene/control/TableView.java

Print this page




3198          *                                                                     *
3199          **********************************************************************/
3200 
3201         /**
3202          * Tests whether the row / cell at the given location currently has the
3203          * focus within the TableView.
3204          */
3205         @Override public boolean isFocused(int row, TableColumn<S,?> column) {
3206             if (row < 0 || row >= getItemCount()) return false;
3207 
3208             TablePosition cell = getFocusedCell();
3209             boolean columnMatch = column == null || column.equals(cell.getTableColumn());
3210 
3211             return cell.getRow() == row && columnMatch;
3212         }
3213 
3214         /**
3215          * Causes the item at the given index to receive the focus. This does not
3216          * cause the current selection to change. Updates the focusedItem and
3217          * focusedIndex properties such that <code>focusedIndex = -1</code> unless
3218          * <pre><code>0 <= index < model size</code></pre>.
3219          *
3220          * @param index The index of the item to get focus.
3221          */
3222         @Override public void focus(int index) {
3223             if (index < 0 || index >= getItemCount()) {
3224                 setFocusedCell(EMPTY_CELL);
3225             } else {
3226                 setFocusedCell(new TablePosition<>(tableView, index, null));
3227             }
3228         }
3229 
3230         /**
3231          * Attempts to move focus to the cell above the currently focused cell.
3232          */
3233         @Override public void focusAboveCell() {
3234             TablePosition cell = getFocusedCell();
3235 
3236             if (getFocusedIndex() == -1) {
3237                 focus(getItemCount() - 1, cell.getTableColumn());
3238             } else if (getFocusedIndex() > 0) {




3198          *                                                                     *
3199          **********************************************************************/
3200 
3201         /**
3202          * Tests whether the row / cell at the given location currently has the
3203          * focus within the TableView.
3204          */
3205         @Override public boolean isFocused(int row, TableColumn<S,?> column) {
3206             if (row < 0 || row >= getItemCount()) return false;
3207 
3208             TablePosition cell = getFocusedCell();
3209             boolean columnMatch = column == null || column.equals(cell.getTableColumn());
3210 
3211             return cell.getRow() == row && columnMatch;
3212         }
3213 
3214         /**
3215          * Causes the item at the given index to receive the focus. This does not
3216          * cause the current selection to change. Updates the focusedItem and
3217          * focusedIndex properties such that <code>focusedIndex = -1</code> unless
3218          * <pre><code>0 &lt;= index &lt; model size</code></pre>.
3219          *
3220          * @param index The index of the item to get focus.
3221          */
3222         @Override public void focus(int index) {
3223             if (index < 0 || index >= getItemCount()) {
3224                 setFocusedCell(EMPTY_CELL);
3225             } else {
3226                 setFocusedCell(new TablePosition<>(tableView, index, null));
3227             }
3228         }
3229 
3230         /**
3231          * Attempts to move focus to the cell above the currently focused cell.
3232          */
3233         @Override public void focusAboveCell() {
3234             TablePosition cell = getFocusedCell();
3235 
3236             if (getFocusedIndex() == -1) {
3237                 focus(getItemCount() - 1, cell.getTableColumn());
3238             } else if (getFocusedIndex() > 0) {


< prev index next >