ArrayList<Column> columns = getShownColumns(); for ( Column column : columns ) { TableColumn tableColumn = new TableColumn( table, column.getStyle() ); tableColumn.setText( column.getTitle() ); tableColumn.setWidth( column.getWidth() ); }
/** * Restore the width of the specified column to its previous width */ private void restoreColumn(int column) { TableColumn tableColumn = this.tableAdjust.getColumnModel().getColumn(column); Integer width = this.columnSizes.get(tableColumn); if (width != null) { this.tableAdjust.getTableHeader().setResizingColumn(tableColumn); tableColumn.setWidth( width.intValue() ); } }
private void setColumnWith(final JTable table, final int columnIndex, final int minSize, final int preferredSize, final Integer maxSize) { final TableColumn column = table.getColumnModel().getColumn(columnIndex); column.setMinWidth(minSize); column.setWidth(preferredSize); column.setPreferredWidth(preferredSize); if (maxSize != null) { column.setMaxWidth(maxSize); } }
/** * 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); }
col.setWidth(width);
public static void setColumnWidthAndOrder(JTable table, int[] defaultColumnsWidth, String widthPrefKey, String orderPrefKey) { table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // set the column width from saved value or defaults int[] widths = getIntArrayFromString(PreferencesDialog.getCachedValue(widthPrefKey, null)); int i = 0; for (int width : defaultColumnsWidth) { if (widths != null && widths.length > i) { width = widths[i]; } if (table.getColumnModel().getColumnCount() >= i) { TableColumn column = table.getColumnModel().getColumn(i++); column.setWidth(width); column.setPreferredWidth(width); } else { break; } } // set the column order int[] order = getIntArrayFromString(PreferencesDialog.getCachedValue(orderPrefKey, null)); if (order != null && order.length == table.getColumnCount()) { for (int j = 0; j < table.getColumnCount(); j++) { table.moveColumn(table.convertColumnIndexToView(order[j]), j); } } }
column.setWidth(100); TableViewerColumn firstNameCol = new TableViewerColumn(viewer, column); firstNameCol.setLabelProvider(new ColumnLabelProvider(){ column.setWidth(100); TableViewerColumn lastNameCol = new TableViewerColumn(viewer, column); lastNameCol.setLabelProvider(new ColumnLabelProvider(){ column.setWidth(100); TableViewerColumn actionsNameCol = new TableViewerColumn(viewer, column); actionsNameCol.setLabelProvider(new ColumnLabelProvider(){
/** * * @param tc * @param width */ public static void setColumnWidth(TableColumn tc, int width){ tc.setPreferredWidth(width); tc.setWidth(width); }
private void restoreColumn(int column) { TableColumn tableColumn = table.getColumnModel().getColumn(column); Integer width = columnSizes.get(tableColumn); if (width != null) { table.getTableHeader().setResizingColumn(tableColumn); tableColumn.setWidth(width.intValue()); } }
private void restoreColumn(int column) { TableColumn tableColumn = table.getColumnModel().getColumn(column); Integer width = columnSizes.get(tableColumn); if (width != null) { table.getTableHeader().setResizingColumn(tableColumn); tableColumn.setWidth(width.intValue()); } }
public static void fixTableColumnWidth(JTable table, int columnIndex, int width) { TableColumn column = table.getColumnModel().getColumn(columnIndex); column.setMaxWidth(width); column.setMinWidth(width); column.setWidth(width); column.setPreferredWidth(width); }
public static void fixTableColumnWidth(JTable table, int columnIndex, int width) { TableColumn column = table.getColumnModel().getColumn(columnIndex); column.setMaxWidth(width); column.setMinWidth(width); column.setWidth(width); column.setPreferredWidth(width); }
public void componentResized(ComponentEvent evt){ double pw = table.getParent().getParent().getSize().getWidth(); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableColumn column = table.getColumnModel().getColumn(0); column.setWidth( ((int)pw/2) - 1 ); column.setPreferredWidth( ((int)pw/2) - 1 ); column = table.getColumnModel().getColumn(1); column.setWidth( ((int)pw/2) - 1 ); column.setPreferredWidth( ((int)pw/2) - 1 ); } }
protected final void updateSize() { final int w = getFirstWidth(); if (w > 0) { table_.getColumnModel().getColumn(0).setPreferredWidth(w); table_.getColumnModel().getColumn(0).setWidth(w); } // table_.revalidate(); table_.repaint(); }
public void setColumnWidths() { final JTable theTable = tablePanel.getTable(); InnerTableModel tableModel = (InnerTableModel) theTable.getModel(); TableColumnModel columnModel = theTable.getColumnModel(); for (int i = 0, n = columnModel.getColumnCount(); i < n; i++) { int width = tableModel.getDefaultColumnWidth(i); final TableColumn column = columnModel.getColumn(i); column.setPreferredWidth(width); column.setWidth(width); } }
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); }
/** * Permet d'initialiser les renderer,editor pour ce model. */ public void setRendererAndEditor(final TableColumnModel _m) { TableColumn col= _m.getColumn(0); col.setCellRenderer(BGrapheController.createNameContourRenderer()); col= _m.getColumn(1); col.setCellEditor(BGrapheController.createVisibleCellEditor()); col.setCellRenderer(BGrapheController.createVisibleCellRenderer()); col.setWidth(5); }
private void doStaticLayout() { int width; TableColumn nameColumn; if((width = getSize().width - getColumnModel().getTotalColumnWidth()) == 0) return; nameColumn = getColumnModel().getColumn(convertColumnIndexToView(Column.NAME.ordinal())); if(nameColumn.getWidth() + width >= RESERVED_NAME_COLUMN_WIDTH) nameColumn.setWidth(nameColumn.getWidth() + width); else nameColumn.setWidth(RESERVED_NAME_COLUMN_WIDTH); }
TableViewer tableViewer = new TableViewer(parent); Table table = tableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true);` for (int i = 0; i < COLUMN_NAMES.length; i++) { TableColumn tableColumn = new TableColumn(table, SWT.LEFT); tableColumn.setText(COLUMN_NAMES[i]); tableColumn.setWidth(COLUMN_WIDTHS[i]); } tableViewer.setContentProvider(new ModelContentProvider()); tableViewer.setLabelProvider(new ModelLabelProvider()); tableViewer.setInput(models);