use of javax.swing.table.TableColumn in project beast-mcmc by beast-dev.
the class TableColumnHider method hide.
// END: Constructor
public void hide(String columnName) {
int index = tcm.getColumnIndex(columnName);
TableColumn column = tcm.getColumn(index);
IndexedColumn ic = new IndexedColumn(index, column);
if (hidden.put(columnName, ic) != null) {
throw new IllegalArgumentException("Duplicate column name.");
}
tcm.removeColumn(column);
}
use of javax.swing.table.TableColumn in project beast-mcmc by beast-dev.
the class TaxonSetPanel method initTableColumn.
protected void initTableColumn() {
tableColumnModel = taxonSetsTable.getColumnModel();
TableColumn tableColumn = tableColumnModel.getColumn(0);
tableColumn.setCellRenderer(new TableRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));
tableColumn.setMinWidth(20);
tableColumn = tableColumnModel.getColumn(1);
tableColumn.setPreferredWidth(20);
tableColumn = tableColumnModel.getColumn(2);
tableColumn.setPreferredWidth(20);
tableColumn = tableColumnModel.getColumn(3);
comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
tableColumn.setCellRenderer(comboBoxRenderer);
tableColumn.setPreferredWidth(30);
tableColumn = tableColumnModel.getColumn(4);
tableColumn.setCellEditor(new DateCellEditor(true));
tableColumn.setPreferredWidth(30);
}
use of javax.swing.table.TableColumn in project beast-mcmc by beast-dev.
the class SpeciesSetPanel method initTableColumn.
protected void initTableColumn() {
final TableColumnModel tableColumnModel = taxonSetsTable.getColumnModel();
TableColumn tableColumn = tableColumnModel.getColumn(0);
tableColumn.setCellRenderer(new TableRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));
tableColumn.setMinWidth(20);
tableColumn = tableColumnModel.getColumn(1);
tableColumn.setPreferredWidth(10);
}
use of javax.swing.table.TableColumn in project beast-mcmc by beast-dev.
the class TaxonSetPanel method treeModelsChanged.
protected void treeModelsChanged() {
Object[] modelArray = options.getPartitionTreeModels().toArray();
TableColumn col = tableColumnModel.getColumn(3);
col.setCellEditor(new DefaultCellEditor(new JComboBox(modelArray)));
}
use of javax.swing.table.TableColumn in project cytoscape-api by cytoscape.
the class ColumnResizer method adjustColumnPreferredWidth.
/**
* Adjust one table column to its preferred width.
* @param table The table whose columns should be adjusted.
* @param col The column index.
* @param checkAllRows If false, only the preferred width of the column header is considered.
*/
public static void adjustColumnPreferredWidth(final JTable table, final int col, final boolean checkAllRows) {
// Get max width for cells in column and make that the preferred width
int maxwidth = 0;
if (checkAllRows) {
for (int row = 0; row < table.getRowCount(); row++) {
TableCellRenderer rend = table.getCellRenderer(row, col);
Object value = table.getValueAt(row, col);
Component comp = rend.getTableCellRendererComponent(table, value, false, false, row, col);
maxwidth = Math.max(comp.getPreferredSize().width, maxwidth);
}
}
// This version of the width set considers the column header's preferred width too
TableColumn column = table.getColumnModel().getColumn(col);
TableCellRenderer headerRenderer = column.getHeaderRenderer();
if (headerRenderer == null)
headerRenderer = table.getTableHeader().getDefaultRenderer();
Object headerValue = column.getHeaderValue();
Component headerComp = headerRenderer.getTableCellRendererComponent(table, headerValue, false, false, 0, col);
maxwidth = Math.max(maxwidth, headerComp.getPreferredSize().width);
// If the value is too big, adjust to fixed maximum value
if (DEFLMAX_WIDTH < maxwidth)
maxwidth = DEFLMAX_WIDTH;
column.setPreferredWidth(maxwidth + 20);
}
Aggregations