|
Replies:
14
-
Last Post:
Sep 24, 2008 3:31 AM
by: Qunhuan Mei
|
|
|
|
|
|
|
can I make each of item in a list has different renderer?
Posted:
Sep 23, 2008 5:42 AM
|
|
|
Hi, My program has a list of chat log.But, each of item in a list may be longer than screen's width. So, i try to use flowLayout, BoxLayout.X_axis to wrap the text down in a list, but it didn't work... So, i use 2 container to show the chat log (for only 2 line), cnt is for first line cnt2 is for second line so, i wrap what is over the width of the first line into the second line.
first i type "Abdddada" >> > 1 line http://i374.photobucket.com/albums/oo188/realsub_2008/1.jpg second i type ..string with icon >>> 2 line http://i374.photobucket.com/albums/oo188/realsub_2008/2.jpg for second time,... the 2nd line stretch out the first line to be exactly the same height as itself. Expect result that i want is 1st line should be smaller (single) that 2nd line ... I think, is it related to getListCellRendererComponent method ?????
Any suggestion are welcomed..
Here's my code
class ChatRenderer extends Container implements ListCellRenderer { // private Vector vCnt = new Vector(); private Container cnt = new Container(); private Container cnt2 = new Container(); public ChatRenderer() { this.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); addComponent(cnt); addComponent(cnt2);
} public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
Vector v = (Vector) value; // remove item before adding it cnt.removeAll(); cnt2.removeAll(); int len = 0; for(int i = 0;i<v.size();i++) { Label l = (Label) v.elementAt(i); len += l.getPreferredW(); } int currLen = 0; int indexC = 0; int screenLen = Display.getInstance().getDisplayWidth(); for(int i = 0;i<v.size();i++) { Label l = (Label) v.elementAt(i); currLen += l.getPreferredW(); indexC = (int)Math.ceil((float)currLen /
|
|
|
|
|
|
|
Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 23, 2008 6:01 AM
in response to: sub7
|
|
|
Hi there,
Suppose I have a list of names and want that to appear in a form to be selected individually, I could first initialise a “List� instance with the given name list and add the instance to the form. This way, each item on the form will look like a “list item�. If I want to change the look and feel of individual “list item�, I could use DefaultListCellRender to do that.
However, if I want to change the look and feel of each “list item� to a “Button item�, is there any convenient way to achieve the similar effect as List handling mechanism? Or the only way to do this is adding a list of Buttons with given names to the form, and if any more Button specific action (e.g. adding an icon to the button etc) is required, I should create my own Button to achieve it?
Many thanks,
Qunhuan
|
|
|
|
|
|
|
|
Re: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 23, 2008 6:39 AM
in response to: Qunhuan Mei
|
|
|
|
|
Hi, I'm not exactly clear on what you are trying to achieve from your description. ListCellRenderer can return anything however it has a restriction of assigning the same size for all components except for the selected item. If that restriction is reasonable just go wild with your list cell renderer to achieve any look you want.
> Hi there, > > Suppose I have a list of names and want that to appear in a form to > be selected individually, I could first initialise a “List� > instance with the given name list and add the instance to the form. > This way, each item on the form will look like a “list item�. If I > want to change the look and feel of individual “list item�, I could > use DefaultListCellRender to do that. > > However, if I want to change the look and feel of each “list item� > to a “Button item�, is there any convenient way to achieve the > similar effect as List handling mechanism? Or the only way to do > this is adding a list of Buttons with given names to the form, and > if any more Button specific action (e.g. adding an icon to the > button etc) is required, I should create my own Button to achieve it? > > Many thanks, > > Qunhuan >
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
RE: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 23, 2008 6:47 AM
in response to: Shai Almog
|
|
|
|
|
Hi Shai,
What I want to achieve is a list of "Buttons" on a form, e.g. the same effect by adding a list of "Buttons" to the form. But I also want to change Button's behaviour, e.g. adding icons etc.
Using ListCellRenderer can achieve some look and feel effect but that to me, is based on the "list item" not "Button item". (List or button item has their own specific behaviour).
Still not clear?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:40 To: users@lwuit.dev.java.net Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, I'm not exactly clear on what you are trying to achieve from your description. ListCellRenderer can return anything however it has a restriction of assigning the same size for all components except for the selected item. If that restriction is reasonable just go wild with your list cell renderer to achieve any look you want.
Hi there,
Suppose I have a list of names and want that to appear in a form to be selected individually, I could first initialise a "List" instance with the given name list and add the instance to the form. This way, each item on the form will look like a "list item". If I want to change the look and feel of individual "list item", I could use DefaultListCellRender to do that.
However, if I want to change the look and feel of each "list item" to a "Button item", is there any convenient way to achieve the similar effect as List handling mechanism? Or the only way to do this is adding a list of Buttons with given names to the form, and if any more Button specific action (e.g. adding an icon to the button etc) is required, I should create my own Button to achieve it?
Many thanks,
Qunhuan
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
Re: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 23, 2008 6:56 AM
in response to: Qunhuan Mei
|
|
|
|
|
Hi, sorry I don't understand what you mean by their own behavior?
If you mean no "press" effect then no that won't work and is a pain to do in a list.
You are aware I assume that you can extend button and implement the list cell renderer interface right? You can also set an icon to a button since it derives from Label.
> Hi Shai, > > What I want to achieve is a list of “Buttons� on a form, e.g. the > same effect by adding a list of “Buttons� to the form. But I also > want to change Button’s behaviour, e.g. adding icons etc. > > Using ListCellRenderer can achieve some look and feel effect but > that to me, is based on the “list item� not “Button item�. (List or > button item has their own specific behaviour). > > Still not clear? > > Many thanks, > > Qunhuan > > > From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] > Sent: 23 September 2008 14:40 > To: users@lwuit.dev.java.net > Subject: Re: Is there a convenient way to handle a list of > buttons ...? > > Hi, > I'm not exactly clear on what you are trying to achieve from your > description. ListCellRenderer can return anything however it has a > restriction of assigning the same size for all components except > for the selected item. If that restriction is reasonable just go > wild with your list cell renderer to achieve any look you want. > > > Hi there, > > Suppose I have a list of names and want that to appear in a form to > be selected individually, I could first initialise a “List� > instance with the given name list and add the instance to the form. > This way, each item on the form will look like a “list item�. If I > want to change the look and feel of individual “list item�, I could > use DefaultListCellRender to do that. > > However, if I want to change the look and feel of each “list item� > to a “Button item�, is there any convenient way to achieve the > similar effect as List handling mechanism? Or the only way to do > this is adding a list of Buttons with given names to the form, and > if any more Button specific action (e.g. adding an icon to the > button etc) is required, I should create my own Button to achieve it? > > Many thanks, > > Qunhuan > > > Shai Almog > http://lwuit.blogspot.com/ >
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
RE: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 23, 2008 7:19 AM
in response to: Shai Almog
|
|
|
|
|
Hi Shai,
Please see my comments below:
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:57 To: users@lwuit.dev.java.net Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, sorry I don't understand what you mean by their own behavior? - e.g. focus change animation and press effect.
If you mean no "press" effect then no that won't work and is a pain to do in a list.
- This leads to my original enquiry: shall I say no other way apart from managing a list of Buttons manually (e.g. adding each Button to the form etc)
You are aware I assume that you can extend button and implement the list cell renderer interface right?
- I assume this is to create my own Button (not a list)?
You can also set an icon to a button since it derives from Label. - got this, great!
Hi Shai,
What I want to achieve is a list of "Buttons" on a form, e.g. the same effect by adding a list of "Buttons" to the form. But I also want to change Button's behaviour, e.g. adding icons etc.
Using ListCellRenderer can achieve some look and feel effect but that to me, is based on the "list item" not "Button item". (List or button item has their own specific behaviour).
Still not clear?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:40 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, I'm not exactly clear on what you are trying to achieve from your description. ListCellRenderer can return anything however it has a restriction of assigning the same size for all components except for the selected item. If that restriction is reasonable just go wild with your list cell renderer to achieve any look you want.
Hi there,
Suppose I have a list of names and want that to appear in a form to be selected individually, I could first initialise a "List" instance with the given name list and add the instance to the form. This way, each item on the form will look like a "list item". If I want to change the look and feel of individual "list item", I could use DefaultListCellRender to do that.
However, if I want to change the look and feel of each "list item" to a "Button item", is there any convenient way to achieve the similar effect as List handling mechanism? Or the only way to do this is adding a list of Buttons with given names to the form, and if any more Button specific action (e.g. adding an icon to the button etc) is required, I should create my own Button to achieve it?
Many thanks,
Qunhuan
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
RE: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 23, 2008 7:31 AM
in response to: Qunhuan Mei
|
|
|
|
|
Or do you mean I could create my own DefaultListButtonCellRenderer (which extends Button implements ListCellRenderer)?
(ref: public class DefaultListCellRenderer extends Label<file:// implements ListCellRenderer<file://)
From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] Sent: 23 September 2008 15:20 To: users@lwuit.dev.java.net Subject: RE: Is there a convenient way to handle a list of buttons ...?
Hi Shai,
Please see my comments below:
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:57 To: users@lwuit.dev.java.net Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, sorry I don't understand what you mean by their own behavior? - e.g. focus change animation and press effect.
If you mean no "press" effect then no that won't work and is a pain to do in a list.
- This leads to my original enquiry: shall I say no other way apart from managing a list of Buttons manually (e.g. adding each Button to the form etc)
You are aware I assume that you can extend button and implement the list cell renderer interface right?
- I assume this is to create my own Button (not a list)?
You can also set an icon to a button since it derives from Label. - got this, great!
Hi Shai,
What I want to achieve is a list of "Buttons" on a form, e.g. the same effect by adding a list of "Buttons" to the form. But I also want to change Button's behaviour, e.g. adding icons etc.
Using ListCellRenderer can achieve some look and feel effect but that to me, is based on the "list item" not "Button item". (List or button item has their own specific behaviour).
Still not clear?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:40 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, I'm not exactly clear on what you are trying to achieve from your description. ListCellRenderer can return anything however it has a restriction of assigning the same size for all components except for the selected item. If that restriction is reasonable just go wild with your list cell renderer to achieve any look you want.
Hi there,
Suppose I have a list of names and want that to appear in a form to be selected individually, I could first initialise a "List" instance with the given name list and add the instance to the form. This way, each item on the form will look like a "list item". If I want to change the look and feel of individual "list item", I could use DefaultListCellRender to do that.
However, if I want to change the look and feel of each "list item" to a "Button item", is there any convenient way to achieve the similar effect as List handling mechanism? Or the only way to do this is adding a list of Buttons with given names to the form, and if any more Button specific action (e.g. adding an icon to the button etc) is required, I should create my own Button to achieve it?
Many thanks,
Qunhuan
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
RE: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 23, 2008 8:17 AM
in response to: Qunhuan Mei
|
|
|
|
|
Hi again Shai,
I have done some coding regarding the issue.
I have created a MyList cliass whch has a MyListCellRenderer class in it. The MyListCellRenderer extends Button implements ListCellRenderer.
The cell has got some intrinsic animation, e.g. ticking function.
Here is the problem:
I want to remove the focus changing animation so I have set setSmoothScrolling(false); But this appears to have a side effect: it stops the animation logic working.
Is there any way to change the setSmoothScrolling(false)'s handling logic so that it simply stops the smooth scrolling only but will allow other animation handling to continue ??
Many thanks,
Qunhuan
From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] Sent: 23 September 2008 15:32 To: users@lwuit.dev.java.net Subject: RE: Is there a convenient way to handle a list of buttons ...?
Or do you mean I could create my own DefaultListButtonCellRenderer (which extends Button implements ListCellRenderer)?
(ref: public class DefaultListCellRenderer extends Label<file:// implements ListCellRenderer<file://)
From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] Sent: 23 September 2008 15:20 To: users@lwuit.dev.java.net Subject: RE: Is there a convenient way to handle a list of buttons ...?
Hi Shai,
Please see my comments below:
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:57 To: users@lwuit.dev.java.net Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, sorry I don't understand what you mean by their own behavior? - e.g. focus change animation and press effect.
If you mean no "press" effect then no that won't work and is a pain to do in a list.
- This leads to my original enquiry: shall I say no other way apart from managing a list of Buttons manually (e.g. adding each Button to the form etc)
You are aware I assume that you can extend button and implement the list cell renderer interface right?
- I assume this is to create my own Button (not a list)?
You can also set an icon to a button since it derives from Label. - got this, great!
Hi Shai,
What I want to achieve is a list of "Buttons" on a form, e.g. the same effect by adding a list of "Buttons" to the form. But I also want to change Button's behaviour, e.g. adding icons etc.
Using ListCellRenderer can achieve some look and feel effect but that to me, is based on the "list item" not "Button item". (List or button item has their own specific behaviour).
Still not clear?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:40 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, I'm not exactly clear on what you are trying to achieve from your description. ListCellRenderer can return anything however it has a restriction of assigning the same size for all components except for the selected item. If that restriction is reasonable just go wild with your list cell renderer to achieve any look you want.
Hi there,
Suppose I have a list of names and want that to appear in a form to be selected individually, I could first initialise a "List" instance with the given name list and add the instance to the form. This way, each item on the form will look like a "list item". If I want to change the look and feel of individual "list item", I could use DefaultListCellRender to do that.
However, if I want to change the look and feel of each "list item" to a "Button item", is there any convenient way to achieve the similar effect as List handling mechanism? Or the only way to do this is adding a list of Buttons with given names to the form, and if any more Button specific action (e.g. adding an icon to the button etc) is required, I should create my own Button to achieve it?
Many thanks,
Qunhuan
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
Re: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 23, 2008 8:38 AM
in response to: Qunhuan Mei
|
|
|
|
|
Hi, deriving from button and implementing cell renderer is what I meant (as the renderer sample shows to checkboxes in the LWUIT demo).
However, you won't get a pressed effect. Doing that would be "difficult" so if you need that you should just use a Form.
If you want to disable button ticking there is a flag to disable that the ticker enabled method if I am not mistaken.
> Hi again Shai, > > I have done some coding regarding the issue. > > I have created a MyList cliass whch has a MyListCellRenderer class > in it. The MyListCellRenderer extends Button implements > ListCellRenderer. > > The cell has got some intrinsic animation, e.g. ticking function. > > Here is the problem: > > I want to remove the focus changing animation so I have set > setSmoothScrolling(false); But this appears to have a side effect: > it stops the animation logic working. > > Is there any way to change the setSmoothScrolling(false)’s handling > logic so that it simply stops the smooth scrolling only but will > allow other animation handling to continue ?? > > Many thanks, > > Qunhuan > > > > > From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] > Sent: 23 September 2008 15:32 > To: users@lwuit.dev.java.net > Subject: RE: Is there a convenient way to handle a list of > buttons ...? > > Or do you mean I could create my own DefaultListButtonCellRenderer > (which extends Button implements ListCellRenderer)? > > > (ref: public class DefaultListCellRenderer extends Label implements > ListCellRenderer) > > > > From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] > Sent: 23 September 2008 15:20 > To: users@lwuit.dev.java.net > Subject: RE: Is there a convenient way to handle a list of > buttons ...? > > Hi Shai, > > Please see my comments below: > > From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] > Sent: 23 September 2008 14:57 > To: users@lwuit.dev.java.net > Subject: Re: Is there a convenient way to handle a list of > buttons ...? > > Hi, > sorry I don't understand what you mean by their own behavior? - > e.g. focus change animation and press effect. > > If you mean no "press" effect then no that won't work and is a pain > to do in a list. > - This leads to my original enquiry: shall I say no other > way apart from managing a list of Buttons manually (e.g. adding > each Button to the form etc) > > You are aware I assume that you can extend button and implement the > list cell renderer interface right? > - I assume this is to create my own Button (not a list)? > > > You can also set an icon to a button since it derives from Label. – > got this, great! > > > > Hi Shai, > > What I want to achieve is a list of “Buttons� on a form, e.g. the > same effect by adding a list of “Buttons� to the form. But I also > want to change Button’s behaviour, e.g. adding icons etc. > > Using ListCellRenderer can achieve some look and feel effect but > that to me, is based on the “list item� not “Button item�. (List or > button item has their own specific behaviour). > > Still not clear? > > Many thanks, > > Qunhuan > > > From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] > Sent: 23 September 2008 14:40 > To: users@lwuit.dev.java.net > Subject: Re: Is there a convenient way to handle a list of > buttons ...? > > Hi, > I'm not exactly clear on what you are trying to achieve from your > description. ListCellRenderer can return anything however it has a > restriction of assigning the same size for all components except > for the selected item. If that restriction is reasonable just go > wild with your list cell renderer to achieve any look you want. > > Hi there, > > Suppose I have a list of names and want that to appear in a form to > be selected individually, I could first initialise a “List� > instance with the given name list and add the instance to the form. > This way, each item on the form will look like a “list item�. If I > want to change the look and feel of individual “list item�, I could > use DefaultListCellRender to do that. > > However, if I want to change the look and feel of each “list item� > to a “Button item�, is there any convenient way to achieve the > similar effect as List handling mechanism? Or the only way to do > this is adding a list of Buttons with given names to the form, and > if any more Button specific action (e.g. adding an icon to the > button etc) is required, I should create my own Button to achieve it? > > Many thanks, > > Qunhuan > > > Shai Almog > http://lwuit.blogspot.com/ > > > Shai Almog > http://lwuit.blogspot.com/ >
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
RE: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 23, 2008 9:05 AM
in response to: Shai Almog
|
|
|
|
|
Yes Shai,
I am following your guidance which is how I implemented this particular (Button) cell renderer .
I don't need Button's pressed effect so that is alright.
The button name's auto ticking does not seem to work in this scenario whether I call setTickerEnabled(true) or not. But I can add my own implementation for it so not bad.
I also don't need the list's focus changing animation so I have to call setSmoothScrolling(false). But this stops Button's ticking animation (my own implementation). I can't go without Button's ticking animation.
Is there any way to achieve both (stop list's focus changing animation and keep button name's auto scrolling animation)?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 16:39 To: users@lwuit.dev.java.net Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, deriving from button and implementing cell renderer is what I meant (as the renderer sample shows to checkboxes in the LWUIT demo).
However, you won't get a pressed effect. Doing that would be "difficult" so if you need that you should just use a Form.
If you want to disable button ticking there is a flag to disable that the ticker enabled method if I am not mistaken.
Hi again Shai,
I have done some coding regarding the issue.
I have created a MyList cliass whch has a MyListCellRenderer class in it. The MyListCellRenderer extends Button implements ListCellRenderer.
The cell has got some intrinsic animation, e.g. ticking function.
Here is the problem:
I want to remove the focus changing animation so I have set setSmoothScrolling(false); But this appears to have a side effect: it stops the animation logic working.
Is there any way to change the setSmoothScrolling(false)'s handling logic so that it simply stops the smooth scrolling only but will allow other animation handling to continue ??
Many thanks,
Qunhuan
From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] Sent: 23 September 2008 15:32 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: RE: Is there a convenient way to handle a list of buttons ...?
Or do you mean I could create my own DefaultListButtonCellRenderer (which extends Button implements ListCellRenderer)?
(ref: public class DefaultListCellRenderer extends Label<file:// implements ListCellRenderer<file://)
From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] Sent: 23 September 2008 15:20 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: RE: Is there a convenient way to handle a list of buttons ...?
Hi Shai,
Please see my comments below:
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:57 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, sorry I don't understand what you mean by their own behavior? - e.g. focus change animation and press effect.
If you mean no "press" effect then no that won't work and is a pain to do in a list. - This leads to my original enquiry: shall I say no other way apart from managing a list of Buttons manually (e.g. adding each Button to the form etc)
You are aware I assume that you can extend button and implement the list cell renderer interface right? - I assume this is to create my own Button (not a list)?
You can also set an icon to a button since it derives from Label. - got this, great!
Hi Shai,
What I want to achieve is a list of "Buttons" on a form, e.g. the same effect by adding a list of "Buttons" to the form. But I also want to change Button's behaviour, e.g. adding icons etc.
Using ListCellRenderer can achieve some look and feel effect but that to me, is based on the "list item" not "Button item". (List or button item has their own specific behaviour).
Still not clear?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM<mailto:Shai.Almog@Sun.COM> [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:40 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, I'm not exactly clear on what you are trying to achieve from your description. ListCellRenderer can return anything however it has a restriction of assigning the same size for all components except for the selected item. If that restriction is reasonable just go wild with your list cell renderer to achieve any look you want.
Hi there,
Suppose I have a list of names and want that to appear in a form to be selected individually, I could first initialise a "List" instance with the given name list and add the instance to the form. This way, each item on the form will look like a "list item". If I want to change the look and feel of individual "list item", I could use DefaultListCellRender to do that.
However, if I want to change the look and feel of each "list item" to a "Button item", is there any convenient way to achieve the similar effect as List handling mechanism? Or the only way to do this is adding a list of Buttons with given names to the form, and if any more Button specific action (e.g. adding an icon to the button etc) is required, I should create my own Button to achieve it?
Many thanks,
Qunhuan
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
Re: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 23, 2008 9:39 AM
in response to: Qunhuan Mei
|
|
|
|
|
Hi, make sure to register yourself as animated after calling setSmoothScrolling(false).
> Yes Shai, > > I am following your guidance which is how I implemented this > particular (Button) cell renderer J. > > I don’t need Button’s pressed effect so that is alright. > > The button name’s auto ticking does not seem to work in this > scenario whether I call setTickerEnabled(true) or not. But I can > add my own implementation for it so not bad. > > I also don’t need the list’s focus changing animation so I have to > call setSmoothScrolling(false). But this stops Button’s ticking > animation (my own implementation). I can’t go without Button’s > ticking animation. > > Is there any way to achieve both (stop list’s focus changing > animation and keep button name’s auto scrolling animation)? > > Many thanks, > > Qunhuan > > From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] > Sent: 23 September 2008 16:39 > To: users@lwuit.dev.java.net > Subject: Re: Is there a convenient way to handle a list of > buttons ...? > > Hi, > deriving from button and implementing cell renderer is what I meant > (as the renderer sample shows to checkboxes in the LWUIT demo). > > However, you won't get a pressed effect. Doing that would be > "difficult" so if you need that you should just use a Form. > > If you want to disable button ticking there is a flag to disable > that the ticker enabled method if I am not mistaken. > > > Hi again Shai, > > I have done some coding regarding the issue. > > I have created a MyList cliass whch has a MyListCellRenderer class > in it. The MyListCellRenderer extends Button implements > ListCellRenderer. > > The cell has got some intrinsic animation, e.g. ticking function. > > Here is the problem: > > I want to remove the focus changing animation so I have set > setSmoothScrolling(false); But this appears to have a side effect: > it stops the animation logic working. > > Is there any way to change the setSmoothScrolling(false)’s handling > logic so that it simply stops the smooth scrolling only but will > allow other animation handling to continue ?? > > Many thanks, > > Qunhuan > > > > > From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] > Sent: 23 September 2008 15:32 > To: users@lwuit.dev.java.net > Subject: RE: Is there a convenient way to handle a list of > buttons ...? > > Or do you mean I could create my own DefaultListButtonCellRenderer > (which extends Button implements ListCellRenderer)? > > > (ref: public class DefaultListCellRenderer extends Label implements > ListCellRenderer) > > > > From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] > Sent: 23 September 2008 15:20 > To: users@lwuit.dev.java.net > Subject: RE: Is there a convenient way to handle a list of > buttons ...? > > Hi Shai, > > Please see my comments below: > > From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] > Sent: 23 September 2008 14:57 > To: users@lwuit.dev.java.net > Subject: Re: Is there a convenient way to handle a list of > buttons ...? > > Hi, > sorry I don't understand what you mean by their own behavior? - > e.g. focus change animation and press effect. > > If you mean no "press" effect then no that won't work and is a pain > to do in a list. > - This leads to my original enquiry: shall I say no other > way apart from managing a list of Buttons manually (e.g. adding > each Button to the form etc) > > You are aware I assume that you can extend button and implement the > list cell renderer interface right? > - I assume this is to create my own Button (not a list)? > > > You can also set an icon to a button since it derives from Label. – > got this, great! > > > > Hi Shai, > > What I want to achieve is a list of “Buttons� on a form, e.g. the > same effect by adding a list of “Buttons� to the form. But I also > want to change Button’s behaviour, e.g. adding icons etc. > > Using ListCellRenderer can achieve some look and feel effect but > that to me, is based on the “list item� not “Button item�. (List or > button item has their own specific behaviour). > > Still not clear? > > Many thanks, > > Qunhuan > > > From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] > Sent: 23 September 2008 14:40 > To: users@lwuit.dev.java.net > Subject: Re: Is there a convenient way to handle a list of > buttons ...? > > Hi, > I'm not exactly clear on what you are trying to achieve from your > description. ListCellRenderer can return anything however it has a > restriction of assigning the same size for all components except > for the selected item. If that restriction is reasonable just go > wild with your list cell renderer to achieve any look you want. > > Hi there, > > Suppose I have a list of names and want that to appear in a form to > be selected individually, I could first initialise a “List� > instance with the given name list and add the instance to the form. > This way, each item on the form will look like a “list item�. If I > want to change the look and feel of individual “list item�, I could > use DefaultListCellRender to do that. > > However, if I want to change the look and feel of each “list item� > to a “Button item�, is there any convenient way to achieve the > similar effect as List handling mechanism? Or the only way to do > this is adding a list of Buttons with given names to the form, and > if any more Button specific action (e.g. adding an icon to the > button etc) is required, I should create my own Button to achieve it? > > Many thanks, > > Qunhuan > > > Shai Almog > http://lwuit.blogspot.com/ > > > Shai Almog > http://lwuit.blogspot.com/ > > > Shai Almog > http://lwuit.blogspot.com/ >
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
RE: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 24, 2008 1:11 AM
in response to: Shai Almog
|
|
|
|
|
Shai,
Yes, I did.
What I found is once setSmoothScrolling(false) is called, the inherited animate() is no longer called. I guess setSmoothScrolling(false)'s handling logic could be modified to change this behaviour, am I right?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 17:39 To: users@lwuit.dev.java.net Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, make sure to register yourself as animated after calling setSmoothScrolling(false).
Yes Shai,
I am following your guidance which is how I implemented this particular (Button) cell renderer .
I don't need Button's pressed effect so that is alright.
The button name's auto ticking does not seem to work in this scenario whether I call setTickerEnabled(true) or not. But I can add my own implementation for it so not bad.
I also don't need the list's focus changing animation so I have to call setSmoothScrolling(false). But this stops Button's ticking animation (my own implementation). I can't go without Button's ticking animation.
Is there any way to achieve both (stop list's focus changing animation and keep button name's auto scrolling animation)?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 16:39 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, deriving from button and implementing cell renderer is what I meant (as the renderer sample shows to checkboxes in the LWUIT demo).
However, you won't get a pressed effect. Doing that would be "difficult" so if you need that you should just use a Form.
If you want to disable button ticking there is a flag to disable that the ticker enabled method if I am not mistaken.
Hi again Shai,
I have done some coding regarding the issue.
I have created a MyList cliass whch has a MyListCellRenderer class in it. The MyListCellRenderer extends Button implements ListCellRenderer.
The cell has got some intrinsic animation, e.g. ticking function.
Here is the problem:
I want to remove the focus changing animation so I have set setSmoothScrolling(false); But this appears to have a side effect: it stops the animation logic working.
Is there any way to change the setSmoothScrolling(false)'s handling logic so that it simply stops the smooth scrolling only but will allow other animation handling to continue ??
Many thanks,
Qunhuan
From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] Sent: 23 September 2008 15:32 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: RE: Is there a convenient way to handle a list of buttons ...?
Or do you mean I could create my own DefaultListButtonCellRenderer (which extends Button implements ListCellRenderer)?
(ref: public class DefaultListCellRenderer extends Label<file:// implements ListCellRenderer<file://)
From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] Sent: 23 September 2008 15:20 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: RE: Is there a convenient way to handle a list of buttons ...?
Hi Shai,
Please see my comments below:
From: Shai.Almog@Sun.COM<mailto:Shai.Almog@Sun.COM> [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:57 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, sorry I don't understand what you mean by their own behavior? - e.g. focus change animation and press effect.
If you mean no "press" effect then no that won't work and is a pain to do in a list. - This leads to my original enquiry: shall I say no other way apart from managing a list of Buttons manually (e.g. adding each Button to the form etc)
You are aware I assume that you can extend button and implement the list cell renderer interface right? - I assume this is to create my own Button (not a list)?
You can also set an icon to a button since it derives from Label. - got this, great!
Hi Shai,
What I want to achieve is a list of "Buttons" on a form, e.g. the same effect by adding a list of "Buttons" to the form. But I also want to change Button's behaviour, e.g. adding icons etc.
Using ListCellRenderer can achieve some look and feel effect but that to me, is based on the "list item" not "Button item". (List or button item has their own specific behaviour).
Still not clear?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM<mailto:Shai.Almog@Sun.COM> [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:40 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, I'm not exactly clear on what you are trying to achieve from your description. ListCellRenderer can return anything however it has a restriction of assigning the same size for all components except for the selected item. If that restriction is reasonable just go wild with your list cell renderer to achieve any look you want.
Hi there,
Suppose I have a list of names and want that to appear in a form to be selected individually, I could first initialise a "List" instance with the given name list and add the instance to the form. This way, each item on the form will look like a "list item". If I want to change the look and feel of individual "list item", I could use DefaultListCellRender to do that.
However, if I want to change the look and feel of each "list item" to a "Button item", is there any convenient way to achieve the similar effect as List handling mechanism? Or the only way to do this is adding a list of Buttons with given names to the form, and if any more Button specific action (e.g. adding an icon to the button etc) is required, I should create my own Button to achieve it?
Many thanks,
Qunhuan
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
Re: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 24, 2008 3:11 AM
in response to: Qunhuan Mei
|
|
|
|
|
Hi Qunhuan, please check that you are using the latest sources since we fixed a bug in this area. If this is still occurring please reproduce in a small testcase.
> Shai, > > Yes, I did. > > What I found is once setSmoothScrolling(false) is called, the > inherited animate() is no longer called. I guess setSmoothScrolling > (false)’s handling logic could be modified to change this > behaviour, am I right? > > Many thanks, > > Qunhuan > > From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] > Sent: 23 September 2008 17:39 > To: users@lwuit.dev.java.net > Subject: Re: Is there a convenient way to handle a list of > buttons ...? > > Hi, > make sure to register yourself as animated after calling > setSmoothScrolling(false). > > > Yes Shai, > > I am following your guidance which is how I implemented this > particular (Button) cell renderer J. > > I don’t need Button’s pressed effect so that is alright. > > The button name’s auto ticking does not seem to work in this > scenario whether I call setTickerEnabled(true) or not. But I can > add my own implementation for it so not bad. > > I also don’t need the list’s focus changing animation so I have to > call setSmoothScrolling(false). But this stops Button’s ticking > animation (my own implementation). I can’t go without Button’s > ticking animation. > > Is there any way to achieve both (stop list’s focus changing > animation and keep button name’s auto scrolling animation)? > > Many thanks, > > Qunhuan > > From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] > Sent: 23 September 2008 16:39 > To: users@lwuit.dev.java.net > Subject: Re: Is there a convenient way to handle a list of > buttons ...? > > Hi, > deriving from button and implementing cell renderer is what I meant > (as the renderer sample shows to checkboxes in the LWUIT demo). > > However, you won't get a pressed effect. Doing that would be > "difficult" so if you need that you should just use a Form. > > If you want to disable button ticking there is a flag to disable > that the ticker enabled method if I am not mistaken. > > > > Hi again Shai, > > I have done some coding regarding the issue. > > I have created a MyList cliass whch has a MyListCellRenderer class > in it. The MyListCellRenderer extends Button implements > ListCellRenderer. > > The cell has got some intrinsic animation, e.g. ticking function. > > Here is the problem: > > I want to remove the focus changing animation so I have set > setSmoothScrolling(false); But this appears to have a side effect: > it stops the animation logic working. > > Is there any way to change the setSmoothScrolling(false)’s handling > logic so that it simply stops the smooth scrolling only but will > allow other animation handling to continue ?? > > Many thanks, > > Qunhuan > > > > > From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] > Sent: 23 September 2008 15:32 > To: users@lwuit.dev.java.net > Subject: RE: Is there a convenient way to handle a list of > buttons ...? > > Or do you mean I could create my own DefaultListButtonCellRenderer > (which extends Button implements ListCellRenderer)? > > > (ref: public class DefaultListCellRenderer extends Label implements > ListCellRenderer) > > > > From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] > Sent: 23 September 2008 15:20 > To: users@lwuit.dev.java.net > Subject: RE: Is there a convenient way to handle a list of > buttons ...? > > Hi Shai, > > Please see my comments below: > > From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] > Sent: 23 September 2008 14:57 > To: users@lwuit.dev.java.net > Subject: Re: Is there a convenient way to handle a list of > buttons ...? > > Hi, > sorry I don't understand what you mean by their own behavior? - > e.g. focus change animation and press effect. > > If you mean no "press" effect then no that won't work and is a pain > to do in a list. > - This leads to my original enquiry: shall I say no other > way apart from managing a list of Buttons manually (e.g. adding > each Button to the form etc) > > You are aware I assume that you can extend button and implement the > list cell renderer interface right? > - I assume this is to create my own Button (not a list)? > > > You can also set an icon to a button since it derives from Label. – > got this, great! > > > > Hi Shai, > > What I want to achieve is a list of “Buttons� on a form, e.g. the > same effect by adding a list of “Buttons� to the form. But I also > want to change Button’s behaviour, e.g. adding icons etc. > > Using ListCellRenderer can achieve some look and feel effect but > that to me, is based on the “list item� not “Button item�. (List or > button item has their own specific behaviour). > > Still not clear? > > Many thanks, > > Qunhuan > > > From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] > Sent: 23 September 2008 14:40 > To: users@lwuit.dev.java.net > Subject: Re: Is there a convenient way to handle a list of > buttons ...? > > Hi, > I'm not exactly clear on what you are trying to achieve from your > description. ListCellRenderer can return anything however it has a > restriction of assigning the same size for all components except > for the selected item. If that restriction is reasonable just go > wild with your list cell renderer to achieve any look you want. > > Hi there, > > Suppose I have a list of names and want that to appear in a form to > be selected individually, I could first initialise a “List� > instance with the given name list and add the instance to the form. > This way, each item on the form will look like a “list item�. If I > want to change the look and feel of individual “list item�, I could > use DefaultListCellRender to do that. > > However, if I want to change the look and feel of each “list item� > to a “Button item�, is there any convenient way to achieve the > similar effect as List handling mechanism? Or the only way to do > this is adding a list of Buttons with given names to the form, and > if any more Button specific action (e.g. adding an icon to the > button etc) is required, I should create my own Button to achieve it? > > Many thanks, > > Qunhuan > > > Shai Almog > http://lwuit.blogspot.com/ > > > Shai Almog > http://lwuit.blogspot.com/ > > > Shai Almog > http://lwuit.blogspot.com/ > > > Shai Almog > http://lwuit.blogspot.com/ >
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
RE: Is there a convenient way to handle a list of buttons ...?
Posted:
Sep 24, 2008 3:31 AM
in response to: Shai Almog
|
|
|
|
|
Hi Shai,
I have tested against the latest code and the problem is still there. Will produce a testcase when I have got some free time.
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 24 September 2008 11:11 To: users@lwuit.dev.java.net Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi Qunhuan, please check that you are using the latest sources since we fixed a bug in this area. If this is still occurring please reproduce in a small testcase.
Shai,
Yes, I did.
What I found is once setSmoothScrolling(false) is called, the inherited animate() is no longer called. I guess setSmoothScrolling(false)'s handling logic could be modified to change this behaviour, am I right?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 17:39 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, make sure to register yourself as animated after calling setSmoothScrolling(false).
Yes Shai,
I am following your guidance which is how I implemented this particular (Button) cell renderer .
I don't need Button's pressed effect so that is alright.
The button name's auto ticking does not seem to work in this scenario whether I call setTickerEnabled(true) or not. But I can add my own implementation for it so not bad.
I also don't need the list's focus changing animation so I have to call setSmoothScrolling(false). But this stops Button's ticking animation (my own implementation). I can't go without Button's ticking animation.
Is there any way to achieve both (stop list's focus changing animation and keep button name's auto scrolling animation)?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM<mailto:Shai.Almog@Sun.COM> [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 16:39 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, deriving from button and implementing cell renderer is what I meant (as the renderer sample shows to checkboxes in the LWUIT demo).
However, you won't get a pressed effect. Doing that would be "difficult" so if you need that you should just use a Form.
If you want to disable button ticking there is a flag to disable that the ticker enabled method if I am not mistaken.
Hi again Shai,
I have done some coding regarding the issue.
I have created a MyList cliass whch has a MyListCellRenderer class in it. The MyListCellRenderer extends Button implements ListCellRenderer.
The cell has got some intrinsic animation, e.g. ticking function.
Here is the problem:
I want to remove the focus changing animation so I have set setSmoothScrolling(false); But this appears to have a side effect: it stops the animation logic working.
Is there any way to change the setSmoothScrolling(false)'s handling logic so that it simply stops the smooth scrolling only but will allow other animation handling to continue ??
Many thanks,
Qunhuan
From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] Sent: 23 September 2008 15:32 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: RE: Is there a convenient way to handle a list of buttons ...?
Or do you mean I could create my own DefaultListButtonCellRenderer (which extends Button implements ListCellRenderer)?
(ref: public class DefaultListCellRenderer extends Label<file:// implements ListCellRenderer<file://)
From: Qunhuan Mei [mailto:qunhuan.mei@mfuse.com] Sent: 23 September 2008 15:20 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: RE: Is there a convenient way to handle a list of buttons ...?
Hi Shai,
Please see my comments below:
From: Shai.Almog@Sun.COM<mailto:Shai.Almog@Sun.COM> [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:57 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, sorry I don't understand what you mean by their own behavior? - e.g. focus change animation and press effect.
If you mean no "press" effect then no that won't work and is a pain to do in a list. - This leads to my original enquiry: shall I say no other way apart from managing a list of Buttons manually (e.g. adding each Button to the form etc)
You are aware I assume that you can extend button and implement the list cell renderer interface right? - I assume this is to create my own Button (not a list)?
You can also set an icon to a button since it derives from Label. - got this, great!
Hi Shai,
What I want to achieve is a list of "Buttons" on a form, e.g. the same effect by adding a list of "Buttons" to the form. But I also want to change Button's behaviour, e.g. adding icons etc.
Using ListCellRenderer can achieve some look and feel effect but that to me, is based on the "list item" not "Button item". (List or button item has their own specific behaviour).
Still not clear?
Many thanks,
Qunhuan
From: Shai.Almog@Sun.COM<mailto:Shai.Almog@Sun.COM> [mailto:Shai.Almog@Sun.COM] Sent: 23 September 2008 14:40 To: users@lwuit.dev.java.net<mailto:users@lwuit.dev.java.net> Subject: Re: Is there a convenient way to handle a list of buttons ...?
Hi, I'm not exactly clear on what you are trying to achieve from your description. ListCellRenderer can return anything however it has a restriction of assigning the same size for all components except for the selected item. If that restriction is reasonable just go wild with your list cell renderer to achieve any look you want.
Hi there,
Suppose I have a list of names and want that to appear in a form to be selected individually, I could first initialise a "List" instance with the given name list and add the instance to the form. This way, each item on the form will look like a "list item". If I want to change the look and feel of individual "list item", I could use DefaultListCellRender to do that.
However, if I want to change the look and feel of each "list item" to a "Button item", is there any convenient way to achieve the similar effect as List handling mechanism? Or the only way to do this is adding a list of Buttons with given names to the form, and if any more Button specific action (e.g. adding an icon to the button etc) is required, I should create my own Button to achieve it?
Many thanks,
Qunhuan
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|
|
|
|
Re: can I make each of item in a list has different renderer?
Posted:
Sep 23, 2008 6:37 AM
in response to: sub7
|
|
|
|
|
Hi, this won't work as you expect and probably shouldn't be done in this way a list is designed to scale see: http://lwuit.blogspot.com/2008/08/model-mvc-million-contacts-march.html
You should use a form and components.
> Hi, > My program has a list of chat log.But, each of item in a list may > be longer than screen's width. So, i try to use flowLayout, > BoxLayout.X_axis to wrap the text down in a list, but it didn't > work... > So, i use 2 container to show the chat log (for only 2 line), > cnt is for first line > cnt2 is for second line > so, i wrap what is over the width of the first line into the second > line. > > first i type "Abdddada" >> > 1 line > > second i type ..string with icon >>> 2 line > > for second time,... the 2nd line stretch out the first line to be > exactly the same height as itself. Expect result that i want is > 1st line should be smaller (single) that 2nd line ... > I think, is it related to getListCellRendererComponent > method ????? > > Any suggestion are welcomed.. > > Here's my code > > class ChatRenderer extends Container implements ListCellRenderer > { > // private Vector vCnt = new Vector(); > private Container cnt = new Container(); > private Container cnt2 = new Container(); > public ChatRenderer() > { > this.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); > addComponent(cnt); > addComponent(cnt2); > > } > > public Component getListCellRendererComponent(List list, Object > value, > int index, boolean isSelected) { > > > > Vector v = (Vector) value; > // remove item before adding it > cnt.removeAll(); > cnt2.removeAll(); > > int len = 0; > for(int i = 0;i<v.size();i++) > { > Label l = (Label) v.elementAt(i); > len += l.getPreferredW(); > } > int currLen = 0; > int indexC = 0; > int screenLen = Display.getInstance().getDisplayWidth(); > for(int i = 0;i<v.size();i++) > { > Label l = (Label) v.elementAt(i); > currLen += l.getPreferredW(); > indexC = (int)Math.ceil((float)currLen / (float)screenLen); > > if(indexC == 1) > { > if(!cnt.contains(l)) > { > cnt.addComponent(l); > } > } > else if(indexC == 2) > { > if(!cnt2.contains(l)) > { > cnt2.addComponent(l); > } > } > > > > } > > > > > > > return this; > > } > > public Component getListFocusComponent(List list) { > Label label = new Label(""); > label.getStyle().setBgTransparency(100); > return label; > } > > } > [Message sent by forum member 'sub7' (sub7)] > > http://forums.java.net/jive/thread.jspa?messageID=300976 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net > For additional commands, e-mail: users-help@lwuit.dev.java.net >
Shai Almog http://lwuit.blogspot.com/
[att1.html]
|
|
|
|
|