JDK-7029240 : Tray icon does not show display message
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2011-03-19
  • Updated: 2024-03-25
  • Resolved: 2011-04-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b130)
Java HotSpot(TM) Client VM (build 21.0-b02, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Windows Xp Sp3

A DESCRIPTION OF THE PROBLEM :
Adding an icon to system tray and displaying a popup/message works in 1.6.0_23 but not in 1.7.0-ea.

That is,
compiled with 1.6.0_23 and run with 1.6.0_23 is OK
compiled with 1.6.0_23 and run with 1.7.0-ea is FAIL


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the test case with javac 1.6.0_23 and run with java 1.7.0-ea.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
New icon in system tray and a popup showing a message.
ACTUAL -
Icon appears in system tray but the popup/message goes missing. EDT seems dead...? No menus...

ERROR MESSAGES/STACK TRACES THAT OCCUR :
None. Program just hangs.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class TrayTest implements Runnable {
    private TrayIcon trayicon;

    public static void main(String[] args) {
        if (SystemTray.isSupported()) {
            SwingUtilities.invokeLater(new TrayTest());
        }
    }

    @Override
    public void run() {
        trayicon = new TrayIcon(newIcon(16));
        trayicon.setToolTip("I'm here");
        PopupMenu popup = new PopupMenu();
        popup.add(new MenuItem("Exit")).addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                SystemTray.getSystemTray().remove(trayicon);
                System.exit(0);
            }
        });
        trayicon.setPopupMenu(popup);
        try {
            SystemTray.getSystemTray().add(trayicon);
        } catch (AWTException ex) {
            ex.printStackTrace();
        }
        trayicon.displayMessage("TrayTest", "Started", TrayIcon.MessageType.INFO);
    }

    private BufferedImage newIcon(int size) {
        BufferedImage icon = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = icon.createGraphics();
        g2.setBackground(Color.ORANGE);
        g2.clearRect(0, 0, size, size);
        g2.dispose();
        return icon;
    }
}

---------- END SOURCE ----------

Comments
EVALUATION likely it's a duplicate of 6996708
05-04-2011

EVALUATION It seems that the problem does not have connection with compilation. The issue is reproducible on Windows XP.
05-04-2011

EVALUATION Works on Ubuntu. To compile the test the next imports should be added import java.awt.*; import java.awt.image.*; import java.awt.event.*; import javax.swing.*;
05-04-2011