List of utility methods to do JTable Column Width Set
void | initTableWidth(JTable table, int[] colWiths) init Table Width if (table.getColumnModel().getColumnCount() != colWiths.length) { throw new IllegalArgumentException("Number of Column widths doesn't matched!"); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); for (int i = 0; i < colWiths.length; i++) { TableColumn col = table.getColumnModel().getColumn(i); col.setPreferredWidth(colWiths[i]); |
void | makeTableColumnWidthFit(JTable jTable, int col, int margin) make Table Column Width Fit makeTableColumnWidthFit(jTable, col, margin, false); |
void | setColumnMaxWidths(JTable tbl, Integer... widths) set Column Max Widths TableColumnModel columnModel = tbl.getColumnModel(); for (int i = 0; i < widths.length; i++) { if (widths[i] > -1) { columnModel.getColumn(i).setMaxWidth(widths[i]); |
void | setColumnMinWidths(final JTable table) set the widths of all of the columns to the max width of the object in the column. final TableColumnModel colModel = table.getColumnModel(); final int columns = colModel.getColumnCount(); for (int columnIndex = 0; columnIndex < columns; columnIndex++) { int maxWidth = 0; final TableColumn column = colModel.getColumn(columnIndex); TableCellRenderer renderer = column.getCellRenderer(); if (renderer == null) { renderer = table.getDefaultRenderer(table.getColumnClass(columnIndex)); ... |
void | setColumnSize(TableColumnModel cm, int id, int percent, int tablesize, boolean resizeable) set Column Size TableColumn column = cm.getColumn(id); column.setMinWidth(1); column.setPreferredWidth(tablesize * percent / 100); column.setMaxWidth(tablesize); |
void | setColumnSizes(JTable table, double[] percentages) set Column Sizes Dimension tableDim = table.getPreferredSize(); tableDim = table.getSize(); double total = 0; for (double t : percentages) total += t; table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) { TableColumn column = table.getColumnModel().getColumn(i); ... |
void | setColumnsSize(TableColumnModel cm, int tablesize) set Columns Size boolean resizeable = false;
setColumnSize(cm, FEED_NAME, COLUMN_SIZE_PERCENT_FEED_NAME, tablesize, resizeable);
setColumnSize(cm, FEED_URL, COLUMN_SIZE_PERCENT_FEED_URL, tablesize, resizeable);
setColumnSize(cm, INTERVALL, COLUMN_SIZE_PERCENT_INTERVALL, tablesize, resizeable);
setColumnSize(cm, MONITORED, COLUMN_SIZE_PERCENT_MONITORED, tablesize, resizeable);
|
void | setColumnWidth(JTable table, int columnIdx, int width) set Column Width TableColumn o = table.getColumnModel().getColumn(columnIdx); o.setWidth(width); o.setMaxWidth(width); o.setMinWidth(width); |
void | setColumnWidth(JTable table, int columnIndex, int preferredWidth) set Column Width TableColumn column = getTableColumn(table, columnIndex); if (column == null) { return; column.setPreferredWidth(preferredWidth); |
void | setColumnWidth(JTable table, int columnNumber, int width) set Column Width TableColumn column = table.getColumnModel().getColumn(columnNumber); column.setPreferredWidth(width); column.setWidth(width); |