Search in sources :

Example 81 with TableColumn

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);
}
Also used : TableColumn(javax.swing.table.TableColumn)

Example 82 with TableColumn

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);
}
Also used : TableRenderer(jam.table.TableRenderer) DateCellEditor(dr.app.gui.table.DateCellEditor) TableColumn(javax.swing.table.TableColumn)

Example 83 with TableColumn

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);
}
Also used : TableRenderer(jam.table.TableRenderer) TableColumnModel(javax.swing.table.TableColumnModel) TableColumn(javax.swing.table.TableColumn)

Example 84 with TableColumn

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)));
}
Also used : TableColumn(javax.swing.table.TableColumn)

Example 85 with TableColumn

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);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) Component(java.awt.Component) TableColumn(javax.swing.table.TableColumn)

Aggregations

TableColumn (javax.swing.table.TableColumn)272 TableColumnModel (javax.swing.table.TableColumnModel)75 JTable (javax.swing.JTable)51 TableCellRenderer (javax.swing.table.TableCellRenderer)50 JScrollPane (javax.swing.JScrollPane)44 JPanel (javax.swing.JPanel)33 Component (java.awt.Component)31 JLabel (javax.swing.JLabel)26 BoxLayout (javax.swing.BoxLayout)25 JComboBox (javax.swing.JComboBox)23 ActionEvent (java.awt.event.ActionEvent)21 Dimension (java.awt.Dimension)20 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)20 DefaultCellEditor (javax.swing.DefaultCellEditor)19 ActionListener (java.awt.event.ActionListener)17 JButton (javax.swing.JButton)17 FlowLayout (java.awt.FlowLayout)16 DefaultTableModel (javax.swing.table.DefaultTableModel)15 ArrayList (java.util.ArrayList)14 DefaultTableColumnModel (javax.swing.table.DefaultTableColumnModel)12