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);
}
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);
}
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);
}
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;
}
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();
}
}
});
}
Aggregations