Java JTable Column setSelectedRow(JTable table, int rowIndex, int columnIndex)

Here you can find the source of setSelectedRow(JTable table, int rowIndex, int columnIndex)

Description

set Selected Row

License

Apache License

Declaration

public static void setSelectedRow(JTable table, int rowIndex,
             int columnIndex) 

Method Source Code

    //package com.java2s;
    //License from project: Apache License 

    import javax.swing.*;

    import java.awt.*;

    public class Main {
        public static void setSelectedRow(JTable table, int rowIndex,
                int columnIndex) {
            table.setRowSelectionInterval(rowIndex, columnIndex);
            scrollToSelectedRow(table);//from w w w  .j ava 2s .  c o m
        }

        private static void scrollToSelectedRow(JTable table)
{
   JViewport viewport = (JViewport) table.getParent();
   Rectangle cellRectangle = table.getCellRect(table.getSelectedRow(), 0, true);
   Rectangle visibleRectangle = viewport.getVisibleRect();
   SwingUtilities.invokeLater(() -> table.scrollRectToVisible(new Rectangle(cellRectangle.x, cellRectangle.y, (int) visibleRectangle.getWidth(), (int) visibleRectangle.getHeight())));
}
    }

Related

  1. removeColumn(int index, JTable table)
  2. selectByTyping(JTable table, javax.swing.JTextField textfield, int column)
  3. setColumnOrder(final JTable table, final String positions)
  4. setearPrimerRegistro(JTable pTabla, JTextField pTextoDeBusqueda, int pColumna)
  5. setearTextoDeBusqueda(JTable pTabla, JTextField pTextoDeBusqueda, int pColumna)
  6. setupColumns(JTable table)
  7. sumColumTable(JTable pTable, int pColumna)