Writing a ListCellRenderer
From: kelvSYC (kelvSYC_at_no.email.shaw.ca)
Date: 11/28/03
- Next message: Tobi Krausl: "Re: JComboBox problem, pse help!"
- Previous message: Andrew Thompson: "Re: setLocation problem"
- Next in thread: ak: "Re: Writing a ListCellRenderer"
- Reply: ak: "Re: Writing a ListCellRenderer"
- Reply: Lee Weiner: "Re: Writing a ListCellRenderer"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Next message: Tobi Krausl: "Re: JComboBox problem, pse help!"
- Previous message: Andrew Thompson: "Re: setLocation problem"
- Next in thread: ak: "Re: Writing a ListCellRenderer"
- Reply: ak: "Re: Writing a ListCellRenderer"
- Reply: Lee Weiner: "Re: Writing a ListCellRenderer"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|