问题
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:
Do you think that it is possible ?
Thank you
回答1:
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");
Also try:
TaskItem taskItem = taskBar.getItem(shell);
where shell
is your main application shell. The TaskItem
JavaDoc suggests trying both methods of getting the 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.
来源:https://stackoverflow.com/questions/33104851/display-numbers-on-a-tray-icon-with-swt