开发者

How to use a custom icon with a system tray baloon notification/tooltip using SWT?

I was wondering whether SWT/jface allow for specifying a custom icon (other than predefined SWT.ICON_ERROR | SWT.ICON_INFORMA开发者_如何学编程TION | SWT.ICON_WARNING) for the application system tray item balloon tooltip? I would like to do something like:

ToolTip tip = new ToolTip(shell, SWT.BALLOON);
tip.setText("Notification from a tray item");
tip.setMessage("Here is a message for the user.");
tip.setIcon("/path/to/custom/icon");
trayItem.setToolTip(tip);

I am aware that ToolTip clas does not have the setIcon() method. Is there any other way to achieve this? This would be very useful for application level notifications, etc. Thanks!


This article might help you SWT: Tray Icons and Tooltips.

EDIT

It's not possible, those images are obtained from OS, and cannot be replaced. The setImage() method which are you calling is one of the Tooltip parent's method and the image is completely ignored by Tooltip class.

See source codes for Tooltip SWT class and check the public void setVisible (boolean visible) method (almost at the end), there you can see where are those image icons obtained.

It might be nice feature request for SWT team.

EDIT2

Article about Custom Tooltip in Eclipse 3.1 RCP applications might answer your question. He uses Custom SWT controls from Novocode toolkit, check the BalloonWindow (A Shell wrapper which creates balloon popup windows).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜