Skip to main content

List ticker

2 replies [Last post]
laura_isabel
Offline
Joined: 2009-11-23
Points: 0

Hi,
I have asked this before and I have read and search a lot, but I can't make it work.

I have a list, and each item in the list have two labels. One label is an id and the other one is a name. I want just the label with the name to ticker.

I read this http://lwuit.blogspot.com/2009/10/tickering-everywhere.html and I tried changing the code, but It's not working.

Here is my code:

public class ListaRendererSug extends Container implements ListCellRenderer{

private DefaultListCellRenderer selectedRenderer = new DefaultListCellRenderer(false);
private Label lbId = new Label();
private Label focus = new Label();
private List parentList;

public ListaRendererSug() {
setLayout(new BoxLayout(BoxLayout.X_AXIS));
addComponent(lbId);
addComponent(selectedRenderer);
focus.getStyle().setBgTransparency(100);
}
public boolean animate() {
if (parentList != null && parentList.getComponentForm() != null) {
if (selectedRenderer.isTickerRunning()) {
if (selectedRenderer.animate()) {
parentList.repaint();
}
}
}
return super.animate();
}

public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
Product prod = (Product) value;
value = prod.getName();
lbId.setText(prod.getId());
if (isSelected) {
selectedRenderer.getListCellRendererComponent(list, value, index, isSelected);
if (index == list.getSelectedIndex()) {
if (selectedRenderer.shouldTickerStart()) {
if (!selectedRenderer.isTickerRunning()) {
parentList = list;
try {
list.getComponentForm().registerAnimated(this);
} catch (Exception e) {
}
selectedRenderer.startTicker(UIManager.getInstance().getLookAndFeel().getTickerSpeed(), true);
}
} else {
if (selectedRenderer.isTickerRunning()) {
selectedRenderer.stopTicker();
}
}
}
return this;
} else {
return this;
}
}

public Component getListFocusComponent(List list) {
return null;
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07
Points: 0

Check out the LWUIT4IO IODemo in the SVN (under the extensions directory) look for ResultRenderer.java.

laura_isabel
Offline
Joined: 2009-11-23
Points: 0

Thank you!, thank you!, thank you so much! . It works know. I'm your biggest fan.