Skip to main content

does the two methods in ListCellRenderer works as ActionListener?

2 replies [Last post]
ousys
Offline
Joined: 2008-05-14
Points: 0

Hi, I read the API about listcellrenderer again and again, still doesn't know why we need
the two methods

Component getListCellRendererComponent(List list, java.lang.Object value, int index, boolean isSelected)
Returns a component instance that is already set to render "value".
Component getListFocusComponent(List list)
Rreturns a component instance that paints the list focus item.

If I use a cellrenderer in a list, is it necessary to call these two methods?
is getListCellRendererComponent just to set the cell value of the list?
then what is the parameter of the object value? I need set it by myself, or it works like a actionListener, the value can be automatically got.

getListFocusComponent seems that if I select an item , then it will repaint the part I chose...am I right?

I read the examples in demo--scroll and Renderer, It seems both two the cell value is
given when the Renderer class is created by new Renderer(), right?
is there a way to give the value to display in the cell of list after already have the renderer reference, such as
Renderer renderer=new Renderer();
renderer.setValue(vector);

is it possible?
Looking forward to your replies, thank you .

Regards

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chen

Hi,
Check out this blog post.
http://lwuit.blogspot.com/2008/07/lwuit-list-renderer-by-chen-fishbein.html

Regards,
Chen

lwuit-users@mobileandembedded.org wrote:
> Hi, I read the API about listcellrenderer again and again, still doesn't know why we need
> the two methods
>
> Component getListCellRendererComponent(List list, java.lang.Object value, int index, boolean isSelected)
> Returns a component instance that is already set to render "value".
> Component getListFocusComponent(List list)
> Rreturns a component instance that paints the list focus item.
>
> If I use a cellrenderer in a list, is it necessary to call these two methods?
> is getListCellRendererComponent just to set the cell value of the list?
> then what is the parameter of the object value? I need set it by myself, or it works like a actionListener, the value can be automatically got.
>
> getListFocusComponent seems that if I select an item , then it will repaint the part I chose...am I right?
>
> I read the examples in demo--scroll and Renderer, It seems both two the cell value is
> given when the Renderer class is created by new Renderer(), right?
> is there a way to give the value to display in the cell of list after already have the renderer reference, such as
> Renderer renderer=new Renderer();
> renderer.setValue(vector);
>
> is it possible?
> Looking forward to your replies, thank you .
>
> Regards
> [Message sent by forum member 'ousys' (ousys)]
>
> http://forums.java.net/jive/thread.jspa?messageID=289934
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

ousys
Offline
Joined: 2008-05-14
Points: 0

chen, thank you for you reply , helpful guide, why not place those description in API?

I read your blog , and also read the same topic in Java Swing book and read jdk 5.0 api, and now I understood what the listcellrenderer does and how to use the two methods.

Regards