Java JTable Row Selection fireSelectRow(final JTable table, final int row)

Here you can find the source of fireSelectRow(final JTable table, final int row)

Description

fire Select Row

License

Open Source License

Declaration

public static void fireSelectRow(final JTable table, final int row) 

Method Source Code

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

import java.awt.*;

import javax.swing.*;

public class Main {
    public static void fireSelectRow(final JList list, final Object value) {
        if (value != null) {
            EventQueue.invokeLater(new Runnable() {
                @Override//from   www  .j av a  2  s . c  o m
                public void run() {
                    list.setSelectedValue(value, true);
                }
            });
        }
    }

    public static void fireSelectRow(final JList list, final int row) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                list.setSelectedIndex(row);
            }
        });
    }

    public static void fireSelectRow(final JTable table, final int row) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                if ((row >= 0) && (row < table.getRowCount())) {
                    table.clearSelection();
                    table.setRowSelectionInterval(row, row);
                }
            }
        });
    }
}

Related

  1. getSelectedModelRow(JTable table)
  2. moveRowSelection(JTable pJTable, int pRow)
  3. removeSelectedRowFromTable(JTable table)
  4. selectClickedRow(final JTable table, final MouseEvent event)