代码之家  ›  专栏  ›  技术社区  ›  Rajesh Kumar Dash

有没有办法在任务栏上的EclipseRCP应用程序图标上显示标签/徽章?

  •  0
  • Rajesh Kumar Dash  · 技术社区  · 5 年前

    我想在我的托盘图标上显示一些数字,表示发生在用户身上的一些事件,如在facebook通知图标中所做的操作:

    enter image description here

    你认为有可能吗?

    谢谢你

    0 回复  |  直到 9 年前
        1
  •  1
  •   greg-449    9 年前

    你可以用 TaskBar TaskItem 类,尽管它可能不适用于所有平台。

    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 是您的主要应用程序外壳。这个 任务项 JavaDoc建议尝试两种方法来获取 任务项 :

    为了更好地跨平台支持,应用程序代码应该首先 尝试在主shell的TaskItem上设置此功能,然后在 应用程序的任务项。