Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6589541

TrayIcon.displayMessage() crash

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_02-b05" (amd64)
      java version "1.6.0_02-b05" (i686)


      ADDITIONAL OS VERSION INFORMATION :
      Linux 2.6.20-16-generic #2 SMP Thu Jun 7 19:00:28 UTC 2007 x86_64 GNU/Linux (Ubuntu Feisty)
      Linux 2.6.21-2-686 #1 SMP Wed Jul 11 03:53:02 UTC 2007 i686 GNU/Linux (Debian unstable)


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Server X: X.org
      Window managers : Gnome & KDE


      A DESCRIPTION OF THE PROBLEM :
      A call to TrayIcon.displayMessage() just after JOptionPane.showInputDialog() makes the program crashes.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Call JOptionPane.showInputDialog() for whatever you want, and next call TrayIcon.displayMessage() for whatever you want.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Prompt the user with a nice popup telling him "everything is ok" or "wrong input, your computer will burn".

      ACTUAL -
      Sudden crash : The swing applications is fully stoped immediatly with an error message from X in the terminal (No exception to catch or anything else ; probably because the X server simply disconnected the java app).


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      The program '<unknown>' received an X Window System error.
      This probably reflects a bug in the program.
      The error was 'BadWindow (invalid Window parameter)'.
        (Details: serial 802 error_code 3 request_code 20 minor_code 0)
        (Note to programmers: normally, X errors are reported asynchronously;
         that is, you will receive the error a while after causing it.
         To debug your program, run it with the --sync command line
         option to change this behavior. You can then get a meaningful
         backtrace from your debugger if you break on the gdk_x_error() function.)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.SystemTray;
      import java.awt.TrayIcon;
      import javax.swing.ImageIcon;

      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JButton;

      import javax.swing.JOptionPane;

      public class Test {

      public Test() {
      try {
      javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
      //javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
      } catch(Exception e) {
      System.out.println("Exception while loading the theme : "+e.toString());
      return;
      }

      JFrame frame = new JFrame("plop");

      frame.getContentPane().setLayout(new java.awt.GridLayout(1, 1));
      frame.getContentPane().add(new JLabel("plop", JLabel.CENTER));

      frame.setSize(200, 200);
      frame.setVisible(true);


      SystemTray systray = SystemTray.getSystemTray();
      TrayIcon icon = new TrayIcon(new ImageIcon("blueBunny.png").getImage());

      try {
      systray.add(icon);
      } catch(java.awt.AWTException e) {
      System.out.println("Hm, not the expected crash : "+e.toString());
      return;
      }

      try { Thread.sleep(3000); } catch(InterruptedException e) { /* \_o< */ }

      String toto = JOptionPane.showInputDialog(frame,
      "test",
      "test",
      JOptionPane.QUESTION_MESSAGE);

      icon.displayMessage("test", "test", TrayIcon.MessageType.valueOf("ERROR"));

      try { Thread.sleep(5000); } catch(InterruptedException e) { /* \_o< */ }

      System.exit(0);
      }



      public static void main(String[] args) {
      new Test();
      }

      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      - Use the GTK look and feel.
      - Put a Thread.sleep() between the JOptionPane.showInputDialog() and the TrayIcon.displayMessage()

        Attachments

          Activity

            People

            Assignee:
            denis Denis Fokin (Inactive)
            Reporter:
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: