< prev index next >

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

Print this page




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




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


< prev index next >