2013-01-15 235 views
2

我配置系統托盤的圖標,下面的代碼「SWT」字符串:SWT系統托盤 - Linux的GTK侏儒托盤圖標上盤

/** 
* Configura os ícones da shell principal 
*/ 
protected void setDiplayIcons(Shell shell){ 
    Display display = shell.getDisplay(); 
    InputStream inputImgTray = getClass().getClassLoader().getResourceAsStream(ImagensNaNOffline.IMG_LOGO_SEBRAE.getPath()); 
    Image image = new Image(display, inputImgTray); 
    shell.setImage(image); 

    Tray tray = display.getSystemTray(); 

    final ToolTip tip = new ToolTip(shell, SWT.BALLOON | SWT.ICON_INFORMATION); 
    tip.setMessage("Balloon Message Goes Here!"); 
    if(tray != null) { 
     TrayItem trayItem = new TrayItem(tray, SWT.NONE); 
     trayItem.setImage(image); 
     tip.setText("Balloon Title goes here."); 
     trayItem.setToolTip(tip); 
     final Menu menu = new Menu(shell, SWT.POP_UP); 
     MenuItem menuItem = new MenuItem(menu, SWT.PUSH); 
     menuItem.setText("Button A"); 
     menuItem = new MenuItem(menu, SWT.PUSH); 
     menuItem.setText("Button B"); 
     menuItem = new MenuItem(menu, SWT.PUSH); 
     menuItem.setText("Show Tooltip"); 
     menuItem.addListener (SWT.Selection, new Listener() {   
      public void handleEvent (Event e) { 
       tip.setVisible(true); 
      } 
     });   
     trayItem.addListener (SWT.MenuDetect, new Listener() { 
      public void handleEvent (Event event) { 
       menu.setVisible (true); 
      } 
     });   
    } 

}   

托盤設置OK,但STRING「SWT」是作爲標籤出現在托盤圖標一側。

系統是Fedora Core 17(GNOME)。

這是一個平臺問題還是有辦法改變文本?

下面是截圖:

enter image description here

+1

您可以添加屏幕截圖嗎? – Baz

+0

我沒有添加屏幕截圖的權限。但在Gnome系統托盤中,當我在eclipse中運行時,會發生以下情況:[IMG TRAY] SWT – davidfdr

+0

是的,我知道。只要將它上傳到其他地方併發布鏈接即可。然後我可以在這裏包括它。 – Baz

回答

2

你有一個關於侏儒3.x的誤解 系統托盤位於右下角,使用提供的代碼示例可以正常工作。所以「SWT」位於應用程序標題欄中;顯示的菜單是默認插入了退出菜單項的應用程序菜單。

您的屏幕截圖顯示了桌面的左上角。 「SWT」是使用SWT創建的應用程序的默認回退值。雖然測試我很驚訝,它不符合(主動)窗口的標題。我想這是一個錯誤。有關如何確定應用程序標題的技術細節可以在此問題中找到(Python和PyGTK;一些外部參考):How to set application title in Gnome Shell?

+0

+1爲信息鏈接。 – Baz

+0

https://fabrica.infosolo.com.br/swt_shot3.png有gnome系統托盤的屏幕截圖。我看到Pentaho Data Integration Spoon(使用swt + jface + eclipse格式構建的ETL工具)發生了這種情況。 – davidfdr

+1

這可能是同一個問題。 **請在上傳之前裁剪**屏幕截圖。系統托盤 - 不是全分辨率的兩個屏幕桌面。 – phineas