🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #1271

Re: How to make cellRenderer appear in properties?

#1271
From: Paul Furbacher [TeamB]
Date: Thu, 11 Mar 2004 05:49
65 lines
2952 bytes
nospam wrote:

> I have a jList in a form which I'm writing a cell renderer
> for.  How do I make the cellRenderer available as the
> cellRenderer property in the properties for this control?
> I tried putting the renderer code in the source file
> for Frame1.java (Which is where the jList is), but it
> still doesn't show up as a property.  I also tried 
> adding a class, put the renderer code in the class,
> but it's still not listed.

You should be able to do something like the following:

   public class MyFrame ... {

     ListCellRenderer renderer =
        new MyListCellRenderer();
     ...
   }

Where MyListCellRenderer is declared and defined
in a separate class file.

Or, you may use an anonymous class, as in

   private  ListCellRenderer renderer =
     new DefaultListCellRenderer() {
       public Component getListCellRendererComponent(
         JList list,
         Object value,
         int index,
         boolean isSelected,
         boolean cellHasFocus) {

         return ...;
       }
     };

Then, when you flip to the Designer, "renderer"
should show up in the drop-down list.  At least
that's what I've done in the past and it worked.
You also have to declare "renderer" of type
"ListCellRenderer", not "MyListCellRenderer"
or "DefaultListCellRenderer".

The Designer does not like it if you define
the new renderer class as a nested public
class, or as a class in the same file as
the Frame/Panel class.


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://www.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Technical Details
Message-ID: <404ffdd6$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <pan.2004.03.11.04.13.39.810169@spam.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,edccde8ef22be0d0
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2004-03-10 22:09:39 PST
Date: Thu, 11 Mar 2004 00:49:12 -0500
From: "Paul Furbacher [TeamB]" <pfurbacher@mac.com>
Organization: Reverse Alchemy, Inc.
User-Agent: Mozilla Thunderbird 0.5 (Macintosh/20040208)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: How to make cellRenderer appear in properties?
References: <pan.2004.03.11.04.13.39.810169@spam.com>
In-Reply-To: <pan.2004.03.11.04.13.39.810169@spam.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 68.39.103.120
Message-ID: <404ffdd6$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1078984150 68.39.103.120 (10 Mar 2004 21:49:10 -0800)
Lines: 65
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail