0

I was trying to set ticker on a Label with lwuit 1.5, faced this issue: if I set label.setRTL(true) and then call

label.startTicker(UIManager.getInstance().getLookAndFeel().getTickerSpeed(), true);

ticker just shows first 21 characters of the label's text and ignores the rest.

I've tried:

label.setRTL(false);
label.startTicker(UIManager.getInstance().getLookAndFeel().getTickerSpeed(), true);

it shows up OK, the text goes from left to right, but when I set this in a FocusListener (cause ticker should start when the label receive focus and stop after it loosed focus) it just change direction (goes from right to left).

here's what i do:

Label test = new Label();
Container c1 = new Container(new FlowLayout());


test.setText("1234567890ABCDEFGHIJ1234567890");
test.setFocusable(true);
test.setRTL(false);
test.addFocusListener(new FocusListener (){

        public void focusGained(Component cmpnt) {
            ((Label)cmpnt).setRTL(false);
            ((Label)cmpnt).startTicker(UIManager.getInstance().getLookAndFeel().getTickerSpeed(), false);
        }

        public void focusLost(Component cmpnt) {
            ((Label)cmpnt).stopTicker();
        }
});
c1.addComponent(test);
Ali Ghanavatian
  • 506
  • 1
  • 6
  • 14

2 Answers2

1

Look at setLabelFor, it will ticker the label for test when test gains focus. You should probably set RTL globally in the look and feel class.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
0

I found the problem. wrong direction happens because I've implemented focusListener before adding the label to container (c1). so I just did this:

c1.addComponent(test);
test.addFocusListener(new FocusListener (){

    public void focusGained(Component cmpnt) {
        ((Label)cmpnt).setRTL(false);
        ((Label)cmpnt).startTicker(UIManager.getInstance().getLookAndFeel().getTickerSpeed(), false);
    }

    public void focusLost(Component cmpnt) {
        ((Label)cmpnt).stopTicker();
    }
});

and it simply worked. in fact I got the idea from Label class source code (lines 149 ~ 153):

// solves the case of a user starting a ticker before adding the component
    // into the container
    if(isTickerEnabled() && isTickerRunning() && !isCellRenderer()) {
        getComponentForm().registerAnimatedInternal(this);
    }

this part does not work, but I don't know why. just hope someone fix this bug.

Ali Ghanavatian
  • 506
  • 1
  • 6
  • 14