Java JTable Select moveSelectionDown(JTable table)

Here you can find the source of moveSelectionDown(JTable table)

Description

move Selection Down

License

Open Source License

Declaration

public static void moveSelectionDown(JTable table) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JTable;

public class Main {
    public static void moveSelectionDown(JTable table) {
        int selectedRow = table.getSelectedRow();
        int selectedRowCount = table.getSelectedRowCount();
        int rowCount = table.getRowCount();
        int targetRow;

        if (rowCount == 0) {
            return;
        } else if (rowCount == 1) {
            targetRow = 0;//from  w ww.  j  ava2 s  . com
        } else {
            int bottomRow = selectedRowCount == 1 ? selectedRow : table
                    .getSelectionModel().getMaxSelectionIndex();

            if (bottomRow < rowCount - 1) {
                targetRow = bottomRow + 1;
            } else {
                targetRow = bottomRow;
            }
        }

        table.getSelectionModel()
                .setSelectionInterval(targetRow, targetRow);
    }
}

Related

  1. getSelectedCase(JTable table)
  2. getSelectedObject(JTable table)
  3. getSelectionBackground(JTable t)
  4. invertSelect(JTable table)
  5. invertSelection(JTable table)
  6. selectPositions(final JTable table, final int index0, final int index1)
  7. spaceSelection(final JTable jTable)