Article View: borland.public.jbuilder.java.swing
Article #1170Re: Someone have example jList ListCellRenderer example?
From: nospam
Date: Sat, 20 Mar 2004 13:28
Date: Sat, 20 Mar 2004 13:28
58 lines
2418 bytes
2418 bytes
On Fri, 19 Mar 2004 23:07:11 -0800, John McGrath [TeamB] wrote:
> On 3/19/2004 at 11:55:47 PM, nospam wrote:
>
>> [quoted text muted]
>
> No, because you have not indicated:
>
> 1) What the code does.
> 2) What you expect it to do.
> 3) The context for the code.
The code is in my ListCellRenderer. I would expect it to either
check or uncheck a Jcheckbox in the Jlist, if it is clicked, and
if it has focus. The best I can to is check a box, but not
uncheck it. I've tried NUMEROUS permutations of this.
-Thanks
public class CheckListRenderer extends JCheckBox implements ListCellRenderer {
public CheckListRenderer() {
setOpaque(true);
}
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
{
setText(value.toString());
setBackground(isSelected ? Color.blue : Color.lightGray);
setForeground(isSelected ? Color.white : Color.black);
//WHY DOESN'T THIS CHECK/UNCKECK CHECKBOXES???
if (cellHasFocus) {
if (isSelected) {
setSelected(false);
}
else {
setSelected(true);
}
System.out.print("GOT HERE");
}
return this;
}
Technical Details
Message-ID:
<pan.2004.03.20.13.28.44.699216@spam.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<pan.2004.03.17.02.25.29.868166@spam.com> <405a7347@newsgroups.borland.com> <pan.2004.03.20.04.55.47.68889@spam.com> <405bed9f@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,de66bf01ed98544f X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2004-03-20 05:42:15 PST From: nospam <no@spam.com> Subject: Re: Someone have example jList ListCellRenderer example? Date: Sat, 20 Mar 2004 08:28:45 -0500 User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-ID: <pan.2004.03.20.13.28.44.699216@spam.com> Newsgroups: borland.public.jbuilder.java.swing References: <pan.2004.03.17.02.25.29.868166@spam.com> <405a7347@newsgroups.borland.com> <pan.2004.03.20.04.55.47.68889@spam.com> <405bed9f@newsgroups.borland.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 68.81.92.143 X-Trace: newsgroups.borland.com 1079789323 68.81.92.143 (20 Mar 2004 05:28:43 -0800) Lines: 59 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail