Selection of Custom JTable cell renderer inconsistenent between LAFs
Sorry if that seems cryptic, but I don't know if I've run into a bug or not. I've recently switched from windows to linux and have noticed a problem with one of my programs. I have a "multiline" renderer that I made for my JTable. The renderer isn't terribly elegant, but when I'd select the row of the table, I made the multi-line renderer change its colors in response to the selection.
This color selection switching works fine under the Metal LAF and the Windows LAF. However, this no longer works in the default look and feel is for linux (GTK+?). My multiline renderer in the JTable won't change its foreground/background in response to selection, but will if I use the Metal LAF under linux.
Any idea what I'm doing wrong? Is this a bug? (I'm fairly certain I'm doing something silly, I just can't see it for the life of me).
Here's the code I use to update the selection:
class MultilineRendererextends JTextArea
implements TableCellRenderer{
public MultilineRenderer(){
super();
setWrapStyleWord(false);
setLineWrap(true);
setFont(Const.TABLE_FONT);
setOpaque(true);
}
public Component getTableCellRendererComponent(
JTable table, Object text,
boolean isSelected,boolean hasFocus,
int row,int column){
String data = (String)text;
setText(data);
if (isSelected){
setForeground(table.getSelectionForeground());;
setBackground(table.getSelectionBackground());
}else{
setForeground(table.getForeground());
setBackground(table.getBackground());
}
returnthis;
}
}

