Java TrayIcon verwendet Bild mit transparentem Hintergrund

Ich bin mit dem folgenden code, um ein tray-icon in Windows und Linux. Es funktioniert wunderbar in Windows und einwandfrei unter Linux. In Linux (Ubuntu) ich habe mein panel eingestellt werden (etwas) transparenter, und wenn ich ein GIF (mit transparentem hintergrund) der hintergrund des symbols zeigt sich alles Grau und hässlich (siehe Bild, grüne Diamant "!")....Irgendwelche Ideen auf, wie man das GIF-Bild, ich bin das hinzufügen von "halten" Ihrer transparenten hintergrund?

alt-text http://unarm.org/stackoverflow/panel_task.jpg

und das Bild, das ich benutze, wenn Sie möchten, um zu testen:

alt-text http://unarm.org/stackoverflow/green_info.gif

import java.awt.*;
import java.awt.event.*;

public class TrayFun {


  static class ShowMessageListener implements ActionListener {
    TrayIcon trayIcon;
    String title;
    String message;
    TrayIcon.MessageType messageType;
    ShowMessageListener(
        TrayIcon trayIcon,
        String title,
        String message,
        TrayIcon.MessageType messageType) {
      this.trayIcon = trayIcon;
      this.title = title;
      this.message = message;
      this.messageType = messageType;
    }
    public void actionPerformed(ActionEvent e) {
      trayIcon.displayMessage(title, message, messageType);
    }
  }

  public static void main(String args[]) {
    Runnable runner = new Runnable() {
      public void run() {
        if (SystemTray.isSupported()) {
          final SystemTray tray = SystemTray.getSystemTray();
          Image image = Toolkit.getDefaultToolkit().getImage("green_info.png");
          PopupMenu popup = new PopupMenu();
          final TrayIcon trayIcon = new TrayIcon(image, "The Tip Text", popup);
          trayIcon.setImageAutoSize(true);

          MenuItem item = new MenuItem("Close");
      item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
          tray.remove(trayIcon);
            }
      });
          popup.add(item);
          try {
            tray.add(trayIcon);
          } catch (AWTException e) {
            System.err.println("Can't add to tray");
          }
        } else {
          System.err.println("Tray unavailable");
        }
      }
    };
    EventQueue.invokeLater(runner);
  }
}

InformationsquelleAutor der Frage Jack | 2008-12-01

Schreibe einen Kommentar