private void invokedTableChanged(TableModelEvent e) { if (isStructureChanged(e) || isDataChanged(e)) { updatePreferredRowHeights(); } else if (isUpdate(e) || isInsert(e)) { updatePreferredRowHeights(e.getFirstRow(), e.getLastRow()); } // do nothing on delete } };
/** * * @param table the table which provides the renderers, must not be null * @param row the index of the row in view coordinates * @throws NullPointerException if table is null. * @throws IndexOutOfBoundsException if the row is not a valid row index */ public static void setPreferredRowHeight(JTable table, int row) { int prefHeight = getPreferredRowHeight(table, row); table.setRowHeight(row, prefHeight); }
/** * Sets preferred row heights for all visible rows. * * @param table the table to set row heights to * @throws NullPointerException if no table installed. */ public static void setPreferredRowHeights(JTable table) { // care about visible rows only for (int row = 0; row < table.getRowCount(); row++) { setPreferredRowHeight(table, row); } }
@Override public void tableChanged(final TableModelEvent e) { if (TableUtilities.isInsert(e)) { final int currentRowCount = myTableModel.getRowCount(); if (currentRowCount != lastRowCountScrolledTo) { lastRowCountScrolledTo = currentRowCount; SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false))); } } } });
/** * Returns a boolean indication whether the event represents a * update type. * * @param e the event to examine. * @return true if the event is a true update, false * otherwise. */ public static boolean isUpdate(TableModelEvent e) { if (isStructureChanged(e)) return false; return e.getType() == TableModelEvent.UPDATE && e.getLastRow() < Integer.MAX_VALUE; }
/** * Removes all columns of the given column model. Includes hidden * columns as indicated by the includesHidden flag, the flag has no * effect if the model is not of type TableColumnModelExt.<p> * * @param model the column model to remove all columns from. * @param includeHidden indicates whether hidden columns should be * removed as well, has no effect if model is not of type TableColumnModelExt. */ /* * Stand-in instead of fixing of issue http://java.net/jira/browse/SWINGX-1407 */ public static void clear(TableColumnModel model, boolean includeHidden) { if (model instanceof TableColumnModelExt) { clear(model, ((TableColumnModelExt) model).getColumns(includeHidden)); } else { clear(model, Collections.list(model.getColumns())); } }
@Override public void tableChanged(final TableModelEvent e) { if (TableUtilities.isInsert(e)) { final int currentRowCount = myTableModel.getRowCount(); if (currentRowCount != lastRowCountScrolledTo) { lastRowCountScrolledTo = currentRowCount; SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false))); } } } });
/** * Returns a boolean indication whether the event represents a * update type. * * @param e the event to examine. * @return true if the event is a true update, false * otherwise. */ public static boolean isUpdate(TableModelEvent e) { if (isStructureChanged(e)) return false; return e.getType() == TableModelEvent.UPDATE && e.getLastRow() < Integer.MAX_VALUE; }
/** * Removes all columns of the given column model. Includes hidden * columns as indicated by the includesHidden flag, the flag has no * effect if the model is not of type TableColumnModelExt.<p> * * @param model the column model to remove all columns from. * @param includeHidden indicates whether hidden columns should be * removed as well, has no effect if model is not of type TableColumnModelExt. */ /* * Stand-in instead of fixing of issue http://java.net/jira/browse/SWINGX-1407 */ public static void clear(TableColumnModel model, boolean includeHidden) { if (model instanceof TableColumnModelExt) { clear(model, ((TableColumnModelExt) model).getColumns(includeHidden)); } else { clear(model, Collections.list(model.getColumns())); } }
private void invokedTableChanged(TableModelEvent e) { if (isStructureChanged(e) || isDataChanged(e)) { updatePreferredRowHeights(); } else if (isUpdate(e) || isInsert(e)) { updatePreferredRowHeights(e.getFirstRow(), e.getLastRow()); } // do nothing on delete } };
@Override public void tableChanged(final TableModelEvent e) { if (TableUtilities.isInsert(e)) { final int currentRowCount = myTableModel.getRowCount(); if (currentRowCount != lastRowCountScrolledTo) { lastRowCountScrolledTo = currentRowCount; SwingUtilities.invokeLater(() -> table.scrollRectToVisible(table.getCellRect(myTableModel.getRowCount() - 1, 0, false))); } } } });
/** * Sets preferred row heights for all visible rows. * * @param table the table to set row heights to * @throws NullPointerException if no table installed. */ public static void setPreferredRowHeights(JTable table) { // care about visible rows only for (int row = 0; row < table.getRowCount(); row++) { setPreferredRowHeight(table, row); } }
/** * * @param table the table which provides the renderers, must not be null * @param row the index of the row in view coordinates * @throws NullPointerException if table is null. * @throws IndexOutOfBoundsException if the row is not a valid row index */ public static void setPreferredRowHeight(JTable table, int row) { int prefHeight = getPreferredRowHeight(table, row); table.setRowHeight(row, prefHeight); }
/** * Returns a boolean indication whether the event represents a * update type. * * @param e the event to examine. * @return true if the event is a true update, false * otherwise. */ public static boolean isUpdate(TableModelEvent e) { if (isStructureChanged(e)) return false; return e.getType() == TableModelEvent.UPDATE && e.getLastRow() < Integer.MAX_VALUE; }
/** * Removes all columns of the given column model. Includes hidden * columns as indicated by the includesHidden flag, the flag has no * effect if the model is not of type TableColumnModelExt.<p> * * @param model the column model to remove all columns from. * @param includeHidden indicates whether hidden columns should be * removed as well, has no effect if model is not of type TableColumnModelExt. */ /* * Stand-in instead of fixing of issue http://java.net/jira/browse/SWINGX-1407 */ public static void clear(TableColumnModel model, boolean includeHidden) { if (model instanceof TableColumnModelExt) { clear(model, ((TableColumnModelExt) model).getColumns(includeHidden)); } else { clear(model, Collections.list(model.getColumns())); } }
private void invokedTableChanged(TableModelEvent e) { if (isStructureChanged(e) || isDataChanged(e)) { updatePreferredRowHeights(); } else if (isUpdate(e) || isInsert(e)) { updatePreferredRowHeights(e.getFirstRow(), e.getLastRow()); } // do nothing on delete } };
PwnBackTable() { logTable.getModel().addTableModelListener(e -> { if (TableUtilities.isInsert(e)) { int viewRow = logTable.convertRowIndexToView(e.getFirstRow()); logTable.scrollRectToVisible(logTable.getCellRect(viewRow, 0, true)); } }); logTable.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }); }
/** * Sets preferred row heights for all visible rows. * * @param table the table to set row heights to * @throws NullPointerException if no table installed. */ public static void setPreferredRowHeights(JTable table) { // care about visible rows only for (int row = 0; row < table.getRowCount(); row++) { setPreferredRowHeight(table, row); } }
/** * * @param table the table which provides the renderers, must not be null * @param row the index of the row in view coordinates * @throws NullPointerException if table is null. * @throws IndexOutOfBoundsException if the row is not a valid row index */ public static void setPreferredRowHeight(JTable table, int row) { int prefHeight = getPreferredRowHeight(table, row); table.setRowHeight(row, prefHeight); }
/** * Returns a boolean indication whether the event represents a * update type. * * @param e the event to examine. * @return true if the event is a true update, false * otherwise. */ public static boolean isUpdate(TableModelEvent e) { if (isStructureChanged(e)) return false; return e.getType() == TableModelEvent.UPDATE && e.getLastRow() < Integer.MAX_VALUE; }