Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages
Started by nospam
Thu, 11 Mar 2004 04:13
How to make cellRenderer appear in properties?
Author: nospam
Date: Thu, 11 Mar 2004 04:13
Date: Thu, 11 Mar 2004 04:13
10 lines
1328 bytes
1328 bytes
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. -Thanks
Re: How to make cellRenderer appear in properties?
Author: Paul Furbacher [TeamB]
Date: Thu, 11 Mar 2004 05:49
Date: Thu, 11 Mar 2004 05:49
65 lines
2952 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads