使用SWT在托盘图标上显示数字 [英] Display numbers on a tray icon with SWT

查看:177
本文介绍了使用SWT在托盘图标上显示数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的任务栏图标上显示一些数字,以指示用户发生的许多事件,例如在此Facebook通知图标中所做的事情:

I would like to show some numbers on my tray icon indicating a number of events that happened to the user like what is done in this facebook notifications icons:

您认为有可能吗?

谢谢

推荐答案

尽管不一定在所有平台上都可以使用,但您可以使用TaskBarTaskItem类来实现此目的.

You can do this using the TaskBar and TaskItem classes although it may not work on all platforms.

TaskBar taskBar = Display.getDefault().getSystemTaskBar();
// TODO may return null if not supported on the platform

// Get application item

TaskItem taskItem = taskBar.getItem(null);
if (taskItem != null)
  taskItem.setOverlayText("your text");

也尝试:

TaskItem taskItem = taskBar.getItem(shell);

其中shell是您的主要应用程序外壳. TaskItem JavaDoc建议尝试两种获取TaskItem的方法:

where shell is your main application shell. The TaskItem JavaDoc suggests trying both methods of getting the TaskItem:

为获得更好的跨平台支持,应首先使用应用程序代码 尝试在主外壳的TaskItem上设置此功能,然后在 该应用程序的TaskItem.

For better cross platform support, the application code should first try to set this feature on the TaskItem for the main shell then on the TaskItem for the application.

这篇关于使用SWT在托盘图标上显示数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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