Writing a ListCellRenderer

From: kelvSYC (kelvSYC_at_no.email.shaw.ca)
Date: 11/28/03


Date: Fri, 28 Nov 2003 06:43:19 GMT

I'm writing my own ListCellRenderer for a JList, and I seem to be
running into a problem.

The code below (in getListCellRendererComponent) is supposed to (or so
I am told) appropriately change the color of the selected item so it
stands out (and conforms to a user's preferences, etc). However, when
I actually set the JList's ListCellRenderer to my custom renderer,
nothing happens to the background color or the foreground color. Can
anyone explain why?

      if (isSelected) {
         setBackground(list.getSelectionBackground());
         setForeground(list.getSelectionForeground());
      } else {
         setBackground(list.getBackground());
         setForeground(list.getForeground());
      }

-- 
I am only a mirage.


Relevant Pages

  • Re: Writing a ListCellRenderer
    ... please post complete getListCellRendererComponent() method. ... "kelvSYC" schrieb im Newsbeitrag ... > I'm writing my own ListCellRenderer for a JList, ... > I actually set the JList's ListCellRenderer to my custom renderer, ...
    (comp.lang.java.gui)
  • Re: Writing a ListCellRenderer
    ... >I'm writing my own ListCellRenderer for a JList, ... >I am told) appropriately change the color of the selected item so it ... >I actually set the JList's ListCellRenderer to my custom renderer, ... Lee Weiner ...
    (comp.lang.java.gui)