colWidth = Math.min(colWidth, firstColMaxWidth); } else { colWidth = Math.max(colWidth, width - columnModel.getColumn(0).getPreferredWidth());
JTable table = new JTable(){ @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component component = super.prepareRenderer(renderer, row, column); int rendererWidth = component.getPreferredSize().width; TableColumn tableColumn = getColumnModel().getColumn(column); tableColumn.setPreferredWidth(Math.max(rendererWidth + getIntercellSpacing().width, tableColumn.getPreferredWidth())); return component; } }; table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
/** * Update the TableColumn with the newly calculated width */ private void updateTableColumn(int column, int width) { final TableColumn tableColumn = this.tableAdjust.getColumnModel().getColumn(column); if (! tableColumn.getResizable()) { return; } int calculatedWidth = width; calculatedWidth += this.spacing; // Don't shrink the column width if (this.isOnlyAdjustLarger) { calculatedWidth = Math.max(calculatedWidth, tableColumn.getPreferredWidth()); } this.columnSizes.put(tableColumn, Integer.valueOf(tableColumn.getWidth())); this.tableAdjust.getTableHeader().setResizingColumn(tableColumn); tableColumn.setWidth(calculatedWidth); }
for (Enumeration<TableColumn> enumeration = header.getColumnModel().getColumns(); enumeration.hasMoreElements();) { TableColumn aColumn = enumeration.nextElement(); width += aColumn.getPreferredWidth();
/** Gets preferred width of table column * @param index column index * @param width preferred column width */ public final int getColumnPreferredWidth(int index) { return table.getColumnModel().getColumn(index).getPreferredWidth(); }
/** Get preferred size of tree view * @return preferred width of tree view */ public final int getTreePreferredWidth() { return treeTable.getColumnModel().getColumn(((TreeTable) treeTable).getTreeColumnIndex()).getPreferredWidth(); }
private void fixNameColumnWidth(int viewWidth) { TableColumn nameCol= detailsTable.getColumnModel().getColumn(COLUMN_FILENAME); int tableWidth= detailsTable.getPreferredSize().width; if (tableWidth < viewWidth) { nameCol.setPreferredWidth( nameCol.getPreferredWidth() + viewWidth - tableWidth); } }
JTable table = new JTable(){ @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component component = super.prepareRenderer(renderer, row, column); int rendererWidth = component.getPreferredSize().width; TableColumn tableColumn = getColumnModel().getColumn(column); tableColumn.setPreferredWidth(Math.max(rendererWidth + getIntercellSpacing().width, tableColumn.getPreferredWidth())); return component; } }; table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
/** Gets preferred width of table column * @param index column index * @return preferred column width */ public final int getTableColumnPreferredWidth(int index) { int j = tableModel.getVisibleIndex(index); if (j != -1) { return treeTable.getColumnModel().getColumn(j + 1).getPreferredWidth(); } else { return tableModel.getArrayColumnWidth(index); } }
private void updateTableColumn(int column, int width) { final TableColumn tableColumn = table.getColumnModel().getColumn(column); if (!tableColumn.getResizable()) return; width += spacing; // Don't shrink the column width if (isOnlyAdjustLarger) { width = Math.max(width, tableColumn.getPreferredWidth()); } columnSizes.put(tableColumn, tableColumn.getWidth()); table.getTableHeader().setResizingColumn(tableColumn); tableColumn.setWidth(width); }
private void saveColumnsData() { int index; TableColumnModel colModel = resTable.getColumnModel(); for (int i = 0; i < resTableModel.getColumnCount(); i++) { index = resTableModel.getRealColumn(i); if (index != 0) { columnWidths[index - 1] = colModel.getColumn(i).getPreferredWidth(); } } }
private void saveColumnsData() { int index; TableColumnModel colModel = resTable.getColumnModel(); for (int i = 0; i < resTableModel.getColumnCount(); i++) { index = resTableModel.getRealColumn(i); if (index != 0) { columnWidths[index - 1] = colModel.getColumn(i).getPreferredWidth(); } } }
private void saveColumnsData() { int index; TableColumnModel colModel = resTable.getColumnModel(); for (int i = 0; i < resTableModel.getColumnCount(); i++) { index = resTableModel.getRealColumn(i); if (index != 0) { columnWidths[index - 1] = colModel.getColumn(i).getPreferredWidth(); } } }
public void addDefaultPerspective(String name, int autoResizeMode, int[] positions, boolean[] visibles) { SyTableColumnModel ytcm = (SyTableColumnModel) getColumnModel(); List<TableColumn> initialColumns = ytcm.getColumns(true, true); int[] sizes = new int[visibles.length]; for (int i = 0; i < sizes.length; i++) { sizes[i] = initialColumns.get(i).getPreferredWidth(); } addDefaultPerspective(name, autoResizeMode, positions, visibles, sizes); }
private void pack() { final TableColumn checkCol = getColumnModel().getColumn(0); if (headerRenderer != null){ checkCol.setHeaderRenderer(headerRenderer); } TableUtils.pack(this, true, true, 2); if (checkCol != null){ checkCol.setMaxWidth(checkCol.getPreferredWidth()); checkCol.setResizable(false); } }
private void pack() { final TableColumn checkCol = getColumnModel().getColumn(0); if (headerRenderer != null){ checkCol.setHeaderRenderer(headerRenderer); } TableUtils.pack(this, true, true, 2); if (checkCol != null){ checkCol.setMaxWidth(checkCol.getPreferredWidth()); checkCol.setResizable(false); } }
private void pack() { final TableColumn checkCol = getColumnModel().getColumn(0); if (headerRenderer != null){ checkCol.setHeaderRenderer(headerRenderer); } TableUtils.pack(this, true, true, 2); if (checkCol != null){ checkCol.setMaxWidth(checkCol.getPreferredWidth()); checkCol.setResizable(false); } }
private void saveColumnsData() { int index; TableColumnModel colModel = treeTable.getColumnModel(); for (int i = 0; i < treeTableModel.getColumnCount(); i++) { index = treeTableModel.getRealColumn(i); if (index != 0) { columnWidths[index - 1] = colModel.getColumn(i).getPreferredWidth(); } } columnsVisibility = treeTableModel.getColumnsVisibility(); }
public Rectangle getNodeDimensions(Object value, int row, int depth, boolean expanded, Rectangle bounds) { int wid = Outline.this.getColumnModel().getColumn(0).getPreferredWidth(); bounds.setBounds (0, row * getRowHeight(), wid, getRowHeight()); return bounds; }
protected void saveColumnsData() { int index; TableColumnModel colModel = resTable.getColumnModel(); for (int i = 0; i < resTableModel.getColumnCount(); i++) { index = resTableModel.getRealColumn(i); if (index != 0) { columnWidths[index - 1] = colModel.getColumn(i).getPreferredWidth(); } } columnsVisibility = resTableModel.getColumnsVisibility(); }