I have a custom JTable renderer extending JSpinner. It seems that I
cannot set the foreground or background colors ( setForeground(color)
and setBackground(color) don't change any colors). Anyone have any
suggestions? - Lou
> I have a custom JTable renderer extending JSpinner. It seems that I
> cannot set the foreground or background colors ( setForeground(color)
> and setBackground(color) don't change any colors). Anyone have any
> suggestions? - Lou
jSpinner = new JSpinner();
JComponent editor = jSpinner.getEditor();
if (editor instanceof JSpinner.DefaultEditor) {
JSpinner.DefaultEditor defEditor = (JSpinner.DefaultEditor) editor;
JFormattedTextField tf = defEditor.getTextField();
if (tf != null) {
tf.setBackground(Color.RED);
tf.setForeground(Color.WHITE);
}
}

Signature
Regards,
Roland de Ruiter
___ ___
/__/ w_/ /__/
/ \ /_/ / \
Lou Lipnickey - 10 Mar 2005 03:17 GMT
Thanks, I also got the following to work:
JFormattedTextField tf =
((JSpinner.DefaultEditor)this.getEditor()).getTextField();
if (isSelected)
{
tf.setForeground(table.getSelectionForeground());
tf.setBackground(table.getSelectionBackground());
}
else
{
tf.setForeground(table.getForeground());
tf.setBackground(table.getBackground());
}
>> I have a custom JTable renderer extending JSpinner. It seems that I
>> cannot set the foreground or background colors ( setForeground(color)
[quoted text clipped - 11 lines]
> }
> }