Search in sources :

Example 61 with JTableHeader

use of javax.swing.table.JTableHeader in project knime-core by knime.

the class PMCCNodeView method changeRenderer.

private void changeRenderer(final String renderer) {
    TableContentView tcv = m_tableView.getContentTable();
    tcv.changeRenderer(DoubleCell.TYPE, renderer);
    Component c = m_tableView.getCorner(JScrollPane.UPPER_LEFT_CORNER);
    LegendCornerAll cornerRenderer = null;
    if (c instanceof JTableHeader) {
        JTableHeader corner = (JTableHeader) c;
        TableCellRenderer ren = corner.getDefaultRenderer();
        if (ren instanceof LegendCornerAll) {
            cornerRenderer = (LegendCornerAll) ren;
        }
    }
    if (cornerRenderer != null) {
        if (renderer.equals(ColorRender.DESCRIPTION)) {
            cornerRenderer.setPaintLegend(true);
            // no need to set column header height, done by label UI
            tcv.setColumnWidth(15);
            TableCellRenderer r = m_tableView.getContentTable().getTableHeader().getDefaultRenderer();
            if (r instanceof JLabel) {
                ((JLabel) r).setUI(new VerticalLabelUI());
            }
        } else {
            cornerRenderer.setPaintLegend(false);
            m_tableView.setColumnHeaderViewHeight(16);
            tcv.setColumnWidth(75);
            TableCellRenderer r = m_tableView.getContentTable().getTableHeader().getDefaultRenderer();
            if (r instanceof JLabel) {
                ((JLabel) r).updateUI();
            }
        }
    }
    m_currentRendererID = renderer;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JTableHeader(javax.swing.table.JTableHeader) JLabel(javax.swing.JLabel) TableContentView(org.knime.core.node.tableview.TableContentView) Component(java.awt.Component) JComponent(javax.swing.JComponent)

Aggregations

JTableHeader (javax.swing.table.JTableHeader)61 TableCellRenderer (javax.swing.table.TableCellRenderer)18 JTable (javax.swing.JTable)15 Component (java.awt.Component)13 TableColumn (javax.swing.table.TableColumn)12 TableColumnModel (javax.swing.table.TableColumnModel)12 JLabel (javax.swing.JLabel)11 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)8 JComponent (javax.swing.JComponent)7 JScrollPane (javax.swing.JScrollPane)7 BorderLayout (java.awt.BorderLayout)6 MouseEvent (java.awt.event.MouseEvent)6 JPopupMenu (javax.swing.JPopupMenu)6 MouseAdapter (java.awt.event.MouseAdapter)5 JButton (javax.swing.JButton)5 JPanel (javax.swing.JPanel)5 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)4 DefaultTableColumnModel (javax.swing.table.DefaultTableColumnModel)4 FormLayout (com.jgoodies.forms.layout.FormLayout)3 WindowAdapter (java.awt.event.WindowAdapter)3