List of utility methods to do JTable Scroll
void | addHorizontalScrollBar(JTable table, JScrollPane pane) Force l'ajout d'une scrollbar horizontale sur une JTable. table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
pane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL));
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
void | AutoScrollTable(final JTable table_packets) Auto Scroll Table TableModelListener l = new TableModelListener() { @Override public void tableChanged(final TableModelEvent e) { if (e.getType() == TableModelEvent.INSERT) { SwingUtilities.invokeLater(new Runnable() { public void run() { int viewRow = table_packets.convertRowIndexToView(e.getFirstRow()); table_packets.scrollRectToVisible(table_packets.getCellRect(viewRow, 0, true)); ... |
JScrollPane | createTableScrollPane(final JTable table) create Table Scroll Pane table.setRowSorter(new TableRowSorter<>(table.getModel())); return new JScrollPane(table); |
JScrollPane | findScrollPane(JTable p_Table) find Scroll Pane return (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, p_Table); |
JScrollPane | getScrollPane(JTable myTable) get Scroll Pane JScrollPane scroll = new JScrollPane(myTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); myTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); return scroll; |
void | makeTransparant(JTable table, JScrollPane scrollPane) make Transparant table.setOpaque(false); ((DefaultTableCellRenderer) table.getDefaultRenderer(Object.class)).setOpaque(false); ((DefaultTableCellRenderer) table.getDefaultRenderer(String.class)).setOpaque(false); ((JComponent) table.getDefaultRenderer(Boolean.class)).setOpaque(false); scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); |
void | scroll(JTable table, int rowIndex, int vColIndex) Scrolls view if it is located in a JViewport, so that the specified cell is displayed in the center. if (!(table.getParent() instanceof JViewport)) { return; JViewport viewport = (JViewport) table.getParent(); Rectangle rect = table.getCellRect(rowIndex, vColIndex, true); Rectangle viewRect = viewport.getViewRect(); if (viewRect.intersects(rect)) { return; ... |
void | scrollToCenter(JTable table, int rowIndex, int vColIndex) scroll To Center if (!(table.getParent() instanceof JViewport)) { return; JViewport viewport = (JViewport) table.getParent(); Rectangle rect = table.getCellRect(rowIndex, vColIndex, true); Rectangle viewRect = viewport.getViewRect(); rect.setLocation(rect.x - viewRect.x, rect.y - viewRect.y); int centerX = (viewRect.width - rect.width) / 2; ... |
void | scrollToLastSelectedRow(final JTable table) scroll To Last Selected Row if (table == null) { return; int[] selectedRows = table.getSelectedRows(); if (selectedRows.length > 0) { scrollToVisible(table, selectedRows[selectedRows.length - 1], 0); |
void | scrollToPosition(JTable table, int insertRow) scroll To Position Rectangle rectangle = table.getCellRect(insertRow, 1, true); table.scrollRectToVisible(rectangle); |