<Swing Dev> 6179357: Generics: JList: ListCellRenderer & prototypeCellValue

Florian Brunner fbrunnerlist at gmx.ch
Wed Mar 4 01:04:12 UTC 2009


Here is a second sample.

It's not really a  real-world sample, but should be useful to show that also JList of other "value" 
types than String, such as Integer, Long and Short, can profit from generics.

It also shows why JList should specify
ListCellRenderer<? super E> cellRenderer

rather than

ListCellRenderer<E> cellRenderer

(Here: a common Number-cell renderer is used.)

-Florian

Am Dienstag, 3. März 2009 schrieb Alexander Potochkin:
> Hello Tom
>
> It's nice to see you here
>
> >> Could you please provide a complete example of a JList
> >> with a custom ListCellRenderer that proves that renderer should be
> >> generified
> >
> > I bet if you used NetBeans to find implementations of ListCellRenderer
> > even within the JDK most useful implementations would cast the value
> > argument.
>
> anyway, it is always better to have a fixed set of examples to discuss
>
> > (I prefer option 3, btw.)
>
> Thanks
> alexp
>
> > Tom Hawtin


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ListSample2Frame.form
Type: application/xml
Size: 9827 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20090304/5c1617dd/ListSample2Frame.form>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NumberCellRenderer.java
Type: text/x-java
Size: 931 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20090304/5c1617dd/NumberCellRenderer.java>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ListSample2Frame.java
Type: text/x-java
Size: 13229 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20090304/5c1617dd/ListSample2Frame.java>


More information about the swing-dev mailing list