?????????SWT已經提供了對部分平臺(比如window)上的系統托盤的支持。但支持得還不夠好,我最近需要在一個聊天工具實現Balloon效果(粘附于系統托盤上的一個消息氣泡效果,在IM軟件中普遍被支持),查一下SWT API,到目前為上并沒有提供支持。但一個好消息是在月底交要出來的3.2M6中,將對部分API做調整,增加對Balloon的支持。
Milestone?Plan?
3.2
?M6?March?
31
,?
2006
??
?Implement?custom?draw?
for
?table?and?tree?
Implement?
native
?drag?source?effects?
for
?cursor?
Implement?ImageTransfer?support?
Implement?Balloon?tooltips?
Implement?Accessibility?on?Mac?OS?X?
?????這兒是EclipseZone上的一個針對這一效果的文章:TrayIcons and ToolTips ?
http://www.eclipsezone.com/eclipse/forums/t66093.rhtml甚至在官方網站上,已經提供了這一個API的Snippet
//http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet225.java

/**?*//*******************************************************************************
?*?Copyright?(c)?2000,?2006?IBM?Corporation?and?others.
?*?All?rights?reserved.?This?program?and?the?accompanying?materials
?*?are?made?available?under?the?terms?of?the?Eclipse?Public?License?v1.0
?*?which?accompanies?this?distribution,?and?is?available?at
?*?http://www.eclipse.org/legal/epl-v10.html
?*
?*?Contributors:
?*?????IBM?Corporation?-?initial?API?and?implementation
?*******************************************************************************/
package?org.eclipse.swt.snippets;
??

/**//*
?*?Tooltip?example?snippet:?create?a?balloon?tooltip?for?a?tray?item
?*
?*?For?a?list?of?all?SWT?example?snippets?see
?*?http://www.eclipse.org/swt/snippets/
?*?
?*?@since?3.0
?*/
import?org.eclipse.swt.*;
import?org.eclipse.swt.graphics.*;
import?org.eclipse.swt.widgets.*;


public?class?Snippet225?
{


public?static?void?main(String[]?args)?
{
????Display?display?=?new?Display();
????Shell?shell?=?new?Shell(display);
????Image?image?=?null;
????final?ToolTip?tip?=?new?ToolTip(shell,?SWT.BALLOON?|?SWT.ICON_INFORMATION);
????tip.setMessage("Here?is?message?for?the?user.?When?the?message?is?too?long?it?wraps.?I?should?say?something?cool?but?nothing?comes?to?my?mind.");
????Tray?tray?=?display.getSystemTray();

????if?(tray?!=?null)?
{
????????TrayItem?item?=?new?TrayItem(tray,?SWT.NONE);
????????image?=?new?Image(display,?Snippet225.class.getResourceAsStream("eclipse.png"));
????????item.setImage(image);
????????tip.setText("Notification?from?a?tray?item");
????????item.setToolTip(tip);

????}?else?
{
????????tip.setText("Notification?from?anywhere");
????????tip.setLocation(400,?400);
????}
????Button?button?=?new?Button?(shell,?SWT.PUSH);
????button.setText("Press?for?balloon?tip");

????button.addListener(SWT.Selection,?new?Listener()?
{

????????public?void?handleEvent(Event?event)?
{
????????????tip.setVisible(true);
????????}
????});
????button.pack();
????shell.setBounds(50,?50,?300,?200);
????shell.open();

????while?(!shell.isDisposed())?
{
????????if?(!display.readAndDispatch())?display.sleep();
????}
????if?(image?!=?null)?image.dispose();
????display.dispose();
}
}

除此之外,也有其它的第三方API實現了此一效果。是由www.novocode.com提供的BalloonWindow。其API可在上述的網站中獲得。