Java Reference
In-Depth Information
public Object getCellEditorValue() {
return savedColor;
}
private void changeColor(Color color) {
if (color != null) {
savedColor = color;
delegate.setIcon(new DiamondIcon(color));
}
}
public Component getTableCellEditorComponent (JTable table, Object value,
boolean isSelected, int row, int column) {
changeColor((Color)value);
return delegate;
}
}
Figure 18-14 shows the ColorChooserEditor in action, with the associated table in the
background.
Figure 18-14. Pop-up color editor
A sample program using the new ColorChooserEditor is shown in Listing 18-18. The
example reuses the earlier ColorTableModel data model shown in Listing 18-16. Setting up the
ColorChooserEditor simply involves setting the TableCellEditor for the appropriate column.
Search WWH ::




Custom Search