豆沙包

          …… …… 所學(xué) 所寫 所想 所做 所悟…… ……

          SWT中的Sytem Tray相關(guān)處理

          ?????????SWT已經(jīng)提供了對部分平臺(比如window)上的系統(tǒng)托盤的支持。但支持得還不夠好,我最近需要在一個聊天工具實(shí)現(xiàn)Balloon效果(粘附于系統(tǒng)托盤上的一個消息氣泡效果,在IM軟件中普遍被支持),查一下SWT API,到目前為上并沒有提供支持。但一個好消息是在月底交要出來的3.2M6中,將對部分API做調(diào)整,增加對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


          甚至在官方網(wǎng)站上,已經(jīng)提供了這一個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實(shí)現(xiàn)了此一效果。是由www.novocode.com提供的BalloonWindow。其API可在上述的網(wǎng)站中獲得。

          posted on 2006-03-19 16:36 carob 閱讀(879) 評論(0)  編輯  收藏 所屬分類: Eclipse


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 阿坝| 安康市| 阳山县| 页游| 蕲春县| 深水埗区| 湘潭县| 凯里市| 塘沽区| 长宁区| 民县| 通城县| 新安县| 郓城县| 蕉岭县| 云南省| 隆安县| 汝州市| 灵石县| 新晃| 东丰县| 绥中县| 共和县| 武胜县| 荆州市| 北安市| 台中市| 山东省| 西贡区| 万盛区| 中超| 桐庐县| 雅安市| 呼图壁县| 安丘市| 阿坝县| 六盘水市| 霍城县| 霍州市| 乌兰察布市| 鹤庆县|