在SWT中闪烁TableViewer或TreeViewer的背景行 [英] Blinking background rows of TableViewer or TreeViewer in SWT

查看:95
本文介绍了在SWT中闪烁TableViewer或TreeViewer的背景行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够在TableViewer / TreeViewer中为行提供闪烁(红色,可能更多颜色)背景。什么是最好的选择?

I need the ability to have a blinking (red, maybe more colors) background for rows in a TableViewer/TreeViewer. What are the best options?

可能有多个行闪烁,闪烁必须同步,我需要两个闪烁模式,快速和慢。

There may be more than one row blinking, the blinking MUST be synchron and I need two blinking modes, fast and slow.

推荐答案

我会做类似的事情。更新定期更改颜色所需的元素。在每次更新时,根据您希望它们的闪烁方式切换颜色。

I would do something similar to this. Update the elements that you need to change the colors for at a regular interval. At each update toggle the colors depending on how you want them to flash.

void scheduleColorChange(final Color colors[], final int startIndex, final int changeInterval)
{
  getDisplay().timerExec(changeInterval, new Runnable()
  {
    public void run()
    {
      Object[] elements = getColorChangingElements();
      setColorsForFlashingElements(elements, colors[index%colors.length]);
      getViewer().update(elements);
      scheduleColorChange(colors, startIndex+1, changeInterval)
    }
  });
}  

并且您的标签提供商实施IColorProvider。

and the have you label provider implement IColorProvider.

这篇关于在SWT中闪烁TableViewer或TreeViewer的背景行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆