Java Code Examples for javax.swing.table.TableColumn#getMaxWidth()
The following examples show how to use
javax.swing.table.TableColumn#getMaxWidth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableUIBridge.java From darklaf with MIT License | 5 votes |
/** * Return the maximum size of the table. The maximum height is the row heighttimes the number of rows. The maximum * width is the sum of the maximum widths of each column. */ public Dimension getMaximumSize(final JComponent c) { long width = 0; Enumeration<TableColumn> enumeration = table.getColumnModel().getColumns(); while (enumeration.hasMoreElements()) { TableColumn aColumn = enumeration.nextElement(); width = width + aColumn.getMaxWidth(); } return createTableSize(width); }
Example 2
Source File: UIUtil.java From netbeans with Apache License 2.0 | 5 votes |
public static void updateColumnWidths(JTable table) { double pw = table.getParent().getSize().getWidth(); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableColumn column = table.getColumnModel().getColumn(1); int w = ((int) pw / 2) - 1; if (w > column.getMaxWidth()) { w = column.getMaxWidth(); } column.setWidth(w); column.setPreferredWidth(w); w = (int) pw - w; column = table.getColumnModel().getColumn(0); column.setWidth(w); column.setPreferredWidth(w); }
Example 3
Source File: EditableTableHeaderColumn.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
public void copyValues(TableColumn base) { modelIndex = base.getModelIndex(); identifier = base.getIdentifier(); width = base.getWidth(); minWidth = base.getMinWidth(); setPreferredWidth(base.getPreferredWidth()); maxWidth = base.getMaxWidth(); headerRenderer = base.getHeaderRenderer(); headerValue = base.getHeaderValue(); cellRenderer = base.getCellRenderer(); cellEditor = base.getCellEditor(); isResizable = base.getResizable(); }
Example 4
Source File: MBasicTable.java From javamelody with Apache License 2.0 | 5 votes |
/** * Adapte les largeurs des colonnes selon les données de cette table. <br/> * Pour chaque colonne la taille préférée est déterminée selon la valeur (et le renderer) du header et selon la valeur (et le renderer) de chaque cellule. */ public void adjustColumnWidths() { if (ADJUST_COLUMN_WIDTHS_MAX_ROWS > 0) { TableColumn tableColumn; TableCellRenderer renderer; Object value; Component component; final int columnCount = getColumnCount(); final int rowCount = Math.min(getRowCount(), ADJUST_COLUMN_WIDTHS_MAX_ROWS); int columnWidth; final int maxWidth = 250; // taille ajustée maximum (15 minimum par défaut) // Boucle sur chaque colonne et chaque ligne. // Trouve le max de la largeur du header et de chaque cellule // et fixe la largeur de la colonne en fonction. for (int colNum = 0; colNum < columnCount; colNum++) { tableColumn = columnModel.getColumn(colNum); if (tableColumn.getMaxWidth() <= 0) { continue; // colonne invisible } renderer = getTableHeader().getDefaultRenderer(); value = tableColumn.getHeaderValue(); component = renderer.getTableCellRendererComponent(this, value, false, false, -1, colNum); columnWidth = component.getPreferredSize().width + 10; renderer = getCellRenderer(-1, colNum); for (int rowNum = 0; rowNum < rowCount; rowNum++) { value = getValueAt(rowNum, colNum); component = renderer.getTableCellRendererComponent(this, value, false, false, rowNum, colNum); columnWidth = Math.max(columnWidth, component.getPreferredSize().width); } columnWidth = Math.min(maxWidth, columnWidth); tableColumn.setPreferredWidth(columnWidth + getIntercellSpacing().width); } } }
Example 5
Source File: EditableHeaderTableColumn.java From chipster with MIT License | 5 votes |
public void copyValues(TableColumn base) { modelIndex = base.getModelIndex(); identifier = base.getIdentifier(); width = base.getWidth(); minWidth = base.getMinWidth(); setPreferredWidth(base.getPreferredWidth()); maxWidth = base.getMaxWidth(); headerRenderer = base.getHeaderRenderer(); headerValue = base.getHeaderValue(); cellRenderer = base.getCellRenderer(); cellEditor = base.getCellEditor(); isResizable = base.getResizable(); }
Example 6
Source File: ProfilerColumnModel.java From netbeans with Apache License 2.0 | 4 votes |
boolean isColumnVisible(TableColumn column) { return column.getMaxWidth() > 0; }
Example 7
Source File: ProfilerColumnModel.java From visualvm with GNU General Public License v2.0 | 4 votes |
boolean isColumnVisible(TableColumn column) { return column.getMaxWidth() > 0; }
Example 8
Source File: DatabaseController.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
protected void loadDataViewer( QueryResult queryResult ) { if (queryResult == null) { currentDataTable.setModel(new DefaultTableModel()); return; } Object[] names = queryResult.names.toArray(new String[0]); List<Object[]> data = queryResult.data; Object[][] values = new Object[queryResult.data.size()][]; int index = 0; for( Object[] objects : data ) { values[index++] = objects; for( int i = 0; i < objects.length; i++ ) { if (objects[i] instanceof Date) { Date date = (Date) objects[i]; String formatted = DbsUtilities.dbDateFormatter.format(date); objects[i] = formatted; } } } currentDataTable.setModel(new DefaultTableModel(values, names)); currentDataTable.setCellSelectionEnabled(true); for( int column = 0; column < currentDataTable.getColumnCount(); column++ ) { TableColumn tableColumn = currentDataTable.getColumnModel().getColumn(column); int preferredWidth = tableColumn.getMinWidth(); int maxWidth = tableColumn.getMaxWidth(); for( int row = 0; row < currentDataTable.getRowCount(); row++ ) { TableCellRenderer cellRenderer = currentDataTable.getCellRenderer(row, column); Component c = currentDataTable.prepareRenderer(cellRenderer, row, column); int width = c.getPreferredSize().width + currentDataTable.getIntercellSpacing().width; preferredWidth = Math.max(preferredWidth, width); if (preferredWidth >= maxWidth) { preferredWidth = maxWidth; break; } } if (preferredWidth < 50) { preferredWidth = 50; } if (preferredWidth > 300) { preferredWidth = 300; } tableColumn.setPreferredWidth(preferredWidth); } _recordCountTextfield.setText(values.length + " in " + millisToTimeString(queryResult.queryTimeMillis)); }