01: package com.salmonllc.swing.table;
02:
03: import java.awt.Component;
04: import javax.swing.*;
05:
06: import com.salmonllc.swing.*;
07:
08: public class ComboBoxCellRenderer extends ExpressionCellRenderer {
09: SComboBox _box;
10:
11: public ComboBoxCellRenderer(STable t, SComboBox b) {
12: super (t);
13: _box = b;
14: }
15:
16: public Component getTableCellRendererComponent(JTable table,
17: Object value, boolean isSelected, boolean hasFocus,
18: int row, int column) {
19: JLabel l = (JLabel) super .getTableCellRendererComponent(table,
20: value, isSelected, hasFocus, row, column);
21: ListModel mod = _box.getModel();
22: for (int i = 0; i < mod.getSize(); i++) {
23: Object o = mod.getElementAt(i);
24: if (o instanceof SOption) {
25: if (SComponentHelper.valuesEqual(
26: ((SOption) o).getKey(), value)) {
27: l.setText(((SOption) o).getDisplay());
28: return l;
29: }
30: }
31: }
32: return l;
33: }
34: }
|