سؤال

I am configuring the system tray icons with the following code:

/**
 * 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);
            }
        });         
    }

}           

The tray are set OK but the STRING "SWT" is appearing in the side of Tray Icon as a label.

System is Fedora Core 17 (GNOME).

It is a platform issue or is there a way to change the text?

Here is a screenshot:

enter image description here

هل كانت مفيدة؟

المحلول

You have a misconception about Gnome 3.x. The system tray is located on the bottom right corner and works fine with the supplied code example. So the "SWT" is located in your application title bar; the menu shown is the application menu with a quit menu item inserted by default.

Your screenshot shows the upper left corner of the desktop. "SWT" is a default fallback value of applications created with SWT. Whilst testing I was suprised that it doesn't correspond to the title of the (active) window. I suppose this is a bug. Technical details on how the application title is determined can be found in this question (Python and PyGTK; some external references): How to set application title in Gnome Shell?

نصائح أخرى

I managed to change the application name, thus the text I see in KDE's Systray, by using:

Display.setAppName("Whatever");

Just above all SWT code.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top