His,

if anyone could share experience with achieving blinking behavior for
several items on a page?

in my case there is a table being shown whose rows should have
multiple blinking elements (labels and images). Each of the blinking
elements has -its own- timeout value defined to stop blinking.

The way I have achieved it now, is by creating a composite (see sample
code below) that takes an image/label and adds a timer to it.

I am afraid that that is not a right approach as the table is
constantly being updated to add/delete rows with new blinking
components. That would lead to multiple timers being instantiated and
started  with .scheduleRepeating(XXX); method again and again without
page being reloaded (the page should stay open for a day and display
changing information).

Could anyone comment on my approach: is it memory-leak and performance
degradation prone? What would be a feasible alternative? maybe using
external library like prototype?

Many thanks,
denis


public class BlinkingCorner extends Composite {

    private boolean visible;
    private int blinkingTime = 5000;
    private long timeBlinkingStarted;

    public BlinkingCorner(final Image img) {
        timeBlinkingStarted = System.currentTimeMillis();
        new Timer() {
            @Override
            public void run() {
                if (System.currentTimeMillis() <= timeBlinkingStarted
                        + blinkingTime) {
                    img.setVisible(visible);
                    GWT.log("visible=" + visible, null);
                    visible = !visible;
                } else {
                    GWT.log("cancel", null);
                    img.setVisible(false);
                    cancel();
                }
            }
        }.scheduleRepeating(500);

        initWidget(img);
    }

}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to