Java Utililty Methods JTable Scroll

List of utility methods to do JTable Scroll

Description

The list of methods to do JTable Scroll are organized into topic(s).

Method

voidscrollToVisible(JTable table, int rowIndex, int vColIndex)
Scroll to the given row in a table.
if (!(table.getParent() instanceof JViewport))
    return;
JViewport viewport = (JViewport) table.getParent();
Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);
Point pt = viewport.getViewPosition();
rect.setLocation(rect.x - pt.x, rect.y - pt.y);
table.scrollRectToVisible(rect);
viewport.scrollRectToVisible(rect);
...
voidscrollToVisible(JTable table, int rowIndex, int vColIndex)
scroll To Visible
if (!(table.getParent() instanceof JViewport)) {
    return;
JViewport viewport = (JViewport) table.getParent();
Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);
Point pt = viewport.getViewPosition();
rect.setLocation(rect.x - pt.x, rect.y - pt.y);
viewport.scrollRectToVisible(rect);
...
voidscrollToVisible(JTable table, int rowIndex, int vColIndex)
Scrolls a table so that a certain cell becomes visible.
if (!(table.getParent() instanceof JViewport)) {
    return;
JViewport viewport = (JViewport) table.getParent();
Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);
Point pt = viewport.getViewPosition();
rect.setLocation(rect.x - pt.x, rect.y - pt.y);
table.scrollRectToVisible(rect);
...
voidscrollToVisible(JTable table, int rowIndex, int vColIndex)
scroll To Visible
if (!(table.getParent() instanceof JViewport)) {
    return;
JViewport viewport = (JViewport) table.getParent();
Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);
Point pt = viewport.getViewPosition();
rect.setLocation(rect.x - pt.x, rect.y - pt.y);
viewport.scrollRectToVisible(rect);
...
voidscrollToVisible(JTable table, int rowIndex, int vColIndex)
Scroluje na radek a slopec tabulky
if (!(table.getParent() instanceof JViewport)) {
    return;
JViewport viewport = (JViewport) table.getParent();
Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);
Point pt = viewport.getViewPosition();
rect.setLocation(rect.x - pt.x, rect.y - pt.y);
table.scrollRectToVisible(rect);
...
voidselectAndScroll(JTable table, int rowIndex)
select And Scroll
table.getSelectionModel().setSelectionInterval(rowIndex, rowIndex);
scrollToVisible(table, rowIndex);
voidselectAndScrollToPosition(JTable table, int index0, int index1)
select And Scroll To Position
selectPositions(table, index0, index1);
scrollToPosition(table, index0);
voidselectRow(int row, JTable table, JScrollPane pane)
Selects a the specified row in the specified JTable and scrolls the specified JScrollpane to the newly selected row.
if (table == null || pane == null) {
    return;
if (contains(row, table.getModel()) == false) {
    return;
moveAdjustable(row * table.getRowHeight(), pane.getVerticalScrollBar());
selectRow(row, table.getSelectionModel());
...
voidselectRow(JTable table, int row, boolean bScroll)
select Row
assert (row >= 0 && row < table.getRowCount());
if (row >= 0 && row < table.getRowCount()) {
    table.setRowSelectionInterval(row, row);
    if (bScroll) {
        Rectangle rect = table.getCellRect(row, 0, true);
        table.scrollRectToVisible(rect);
voidshowMessageDialogInScrollableUneditableTextArea(java.awt.Component owner, String text, String title, int messageType, final int maxPreferredWidth, final int maxPreferredHeight)
show Message Dialog In Scrollable Uneditable Text Area
assert (messageType == javax.swing.JOptionPane.ERROR_MESSAGE)
        || (messageType == javax.swing.JOptionPane.INFORMATION_MESSAGE)
        || (messageType == javax.swing.JOptionPane.WARNING_MESSAGE)
        || (messageType == javax.swing.JOptionPane.PLAIN_MESSAGE);
javax.swing.JTextArea textArea = new javax.swing.JTextArea(text);
textArea.setEditable(false);
javax.swing.JOptionPane.showMessageDialog(owner, new javax.swing.JScrollPane(textArea) {
    @Override
...