Search in sources :

Example 56 with DefaultTableCellRenderer

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

the class DBColumnAggregationFunctionPanel method adaptTableColumnModel.

/**
 * {@inheritDoc}
 */
@Override
protected void adaptTableColumnModel(final TableColumnModel columnModel) {
    columnModel.getColumn(0).setCellRenderer(new AggregationFunctionRowTableCellRenderer<>(new ValueRenderer<DBColumnAggregationFunctionRow>() {

        @Override
        public void renderComponent(final DefaultTableCellRenderer c, final DBColumnAggregationFunctionRow row) {
            final DataColumnSpec spec = row.getColumnSpec();
            c.setText(spec.getName());
            c.setIcon(spec.getType().getIcon());
        }
    }, true, "Double click to remove column. Right mouse click for context menu."));
    m_aggregationFunctionCellEditor = new DBColumnAggregationFunctionRowTableCellEditor(null);
    columnModel.getColumn(1).setCellEditor(m_aggregationFunctionCellEditor);
    columnModel.getColumn(1).setCellRenderer(new AggregationFunctionAndRowTableCellRenderer());
    columnModel.getColumn(0).setPreferredWidth(170);
    columnModel.getColumn(1).setPreferredWidth(150);
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) AggregationFunctionAndRowTableCellRenderer(org.knime.base.data.aggregation.dialogutil.AggregationFunctionAndRowTableCellRenderer) ValueRenderer(org.knime.base.data.aggregation.dialogutil.AggregationFunctionRowTableCellRenderer.ValueRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Example 57 with DefaultTableCellRenderer

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

the class AggregationColumnPanel method adaptTableColumnModel.

/**
 * {@inheritDoc}
 */
@Override
protected void adaptTableColumnModel(final TableColumnModel columnModel) {
    columnModel.getColumn(0).setCellRenderer(new AggregationMethodDecoratorTableCellRenderer(new ValueRenderer() {

        @Override
        public void renderComponent(final DefaultTableCellRenderer c, final AggregationMethodDecorator method) {
            if (method instanceof ColumnAggregator) {
                final ColumnAggregator aggregator = (ColumnAggregator) method;
                final DataColumnSpec spec = aggregator.getOriginalColSpec();
                c.setText(spec.getName());
                c.setIcon(spec.getType().getIcon());
            }
        }
    }, true, "Double click to remove column. Right mouse click for context menu."));
    columnModel.getColumn(1).setCellEditor(new ColumnAggregatorTableCellEditor());
    columnModel.getColumn(1).setCellRenderer(new AggregationMethodDecoratorTableCellRenderer(new ValueRenderer() {

        @Override
        public void renderComponent(final DefaultTableCellRenderer c, final AggregationMethodDecorator method) {
            c.setText(method.getLabel());
        }
    }, false));
    columnModel.getColumn(0).setPreferredWidth(170);
    columnModel.getColumn(1).setPreferredWidth(150);
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) AggregationMethodDecorator(org.knime.base.data.aggregation.AggregationMethodDecorator) ColumnAggregatorTableCellEditor(org.knime.base.data.aggregation.dialogutil.column.ColumnAggregatorTableCellEditor) ValueRenderer(org.knime.base.data.aggregation.dialogutil.AggregationMethodDecoratorTableCellRenderer.ValueRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Example 58 with DefaultTableCellRenderer

use of javax.swing.table.DefaultTableCellRenderer in project Spark by igniterealtime.

the class CertificatesManagerSettingsPanel method addCertTableToPanel.

public void addCertTableToPanel() {
    certControll.loadKeyStores();
    certControll.createCertTableModel();
    certTable = new JTable(certControll.getTableModel()) {

        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int columnIndex) {
            JComponent component = (JComponent) super.prepareRenderer(renderer, rowIndex, columnIndex);
            Object value = getModel().getValueAt(convertRowIndexToModel(rowIndex), columnIndex);
            DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
            centerRenderer.setHorizontalAlignment(JLabel.CENTER);
            this.getColumnModel().getColumn(1).setCellRenderer(centerRenderer);
            if (value.equals(Res.getString("cert.valid"))) {
                component.setBackground(Color.green);
            } else if (value.equals(Res.getString("cert.expired")) || value.equals(Res.getString("cert.not.valid.yet")) || value.equals(Res.getString("cert.revoked"))) {
                component.setBackground(Color.red);
            } else {
                component.setBackground(Color.white);
            }
            return component;
        }
    };
    scrollPane = new JScrollPane(certTable);
    certTable.setFillsViewportHeight(true);
    certTable.setAutoCreateRowSorter(true);
    certControll.resizeColumnWidth(certTable);
    certTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
}
Also used : JScrollPane(javax.swing.JScrollPane) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JTable(javax.swing.JTable) JComponent(javax.swing.JComponent) JComponent(javax.swing.JComponent) Component(java.awt.Component) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Example 59 with DefaultTableCellRenderer

use of javax.swing.table.DefaultTableCellRenderer in project lotro-companion by dmorcellet.

the class CraftingSynopsisTableController method buildProfessionCellRenderer.

private TableCellRenderer buildProfessionCellRenderer() {
    TableCellRenderer renderer = new DefaultTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            Profession profession = (Profession) value;
            Icon icon = LotroIconsManager.getProfessionIcon(profession);
            label.setHorizontalAlignment(SwingConstants.CENTER);
            label.setIcon(icon);
            label.setToolTipText(profession.getLabel());
            label.setText("");
            return label;
        }
    };
    return renderer;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) Profession(delta.games.lotro.lore.crafting.Profession) JTable(javax.swing.JTable) JLabel(javax.swing.JLabel) Icon(javax.swing.Icon) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Example 60 with DefaultTableCellRenderer

use of javax.swing.table.DefaultTableCellRenderer in project cytoscape-impl by cytoscape.

the class PreferencesDialog method initTable.

private void initTable() {
    DefaultTableColumnModel cm = new DefaultTableColumnModel();
    for (int i = 0; i < PreferenceTableModel.columnHeader.length; i++) {
        DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
        renderer.setHorizontalAlignment(PreferenceTableModel.alignment[i]);
        TableColumn Column = new TableColumn(i, PreferenceTableModel.columnWidth[i], renderer, null);
        Column.setIdentifier(PreferenceTableModel.columnHeader[i]);
        cm.addColumn(Column);
    }
    prefsTable.setColumnModel(cm);
    prefsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    prefsTable.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && !e.isConsumed()) {
                e.consume();
                if (prefsTable.getSelectedRow() >= 0 && modifyPropBtn.isEnabled())
                    modifyPropBtn.doClick();
            }
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) DefaultTableColumnModel(javax.swing.table.DefaultTableColumnModel) MouseAdapter(java.awt.event.MouseAdapter) TableColumn(javax.swing.table.TableColumn) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Aggregations

DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)85 JTable (javax.swing.JTable)30 TableColumn (javax.swing.table.TableColumn)27 Component (java.awt.Component)21 JScrollPane (javax.swing.JScrollPane)20 DefaultTableModel (javax.swing.table.DefaultTableModel)17 TableCellRenderer (javax.swing.table.TableCellRenderer)17 JLabel (javax.swing.JLabel)14 MouseEvent (java.awt.event.MouseEvent)12 JComponent (javax.swing.JComponent)12 Dimension (java.awt.Dimension)11 Font (java.awt.Font)11 JTableHeader (javax.swing.table.JTableHeader)11 BorderLayout (java.awt.BorderLayout)9 Color (java.awt.Color)9 GridBagConstraints (java.awt.GridBagConstraints)9 Insets (java.awt.Insets)9 JPanel (javax.swing.JPanel)9 GridBagLayout (java.awt.GridBagLayout)7 Point (java.awt.Point)7