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

JDialog always displays an unmodifiable "coffee cup" icon

XMLWordPrintable

    • x86
    • windows_2000

      FULL PRODUCT VERSION :
      java version "1.6.0-ea"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b44)
      Java HotSpot(TM) Client VM (build 1.6.0-ea-b44, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      JDialog always displays an icon for the dialog window. There does not seem to be any API to modify the icon. The icon is always the "java coffee cup" logo, irrespective of any window icon that may have been applied to the parent frame associated with the dialog. The icon is always displayed, irrespective of whether the window is resizeable.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the example code using Java SE 6-ea-b44 on Windows 2000 (or other platforms, that's all I have for testing at this point in time). Look at the displayed windows. In my example, you need to click on the JButton in the JFrame to open the JDialog.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Either the same icon as the parent frame is displayed, or (for consistency with earlier releases) no icon is displayed, given that it called JDialog.setResizable(false).

      Actually, hiding the icon seems to be a bad idea for accessibility, on Windows at least, as the icon's menu provides access to "move window" behavior, but that's an aside.

      What I'd really expect or hope for is that it becomes possible to set a custom icon on dialog boxes.
      ACTUAL -
      I saw the "java coffee cup" icon on the dialog box, not "no icon" or the parent frame's icon.

      Other than in my simple example application (see code example in this bug report), I've observed the same behaviour on other Swing applications running under the same Java release (these problems go away on Java 5 for example).

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      None, it's about visual feedback...

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.awt.*;
      import java.awt.image.BufferedImage;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import javax.swing.*;

      public class DialogTest
      {
      public static void main(String[] args)
      {
      final JFrame frame = new JFrame("Dialog test");
      final JButton openingButton = new JButton("Open dialog");

      frame.setIconImage(createIconImage(Color.RED));

      openingButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e)
      {
      final JDialog dialog = new JDialog(frame,"Modal dialog",true);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
      dialog.setModal(true);

      final JButton closingButton = new JButton("Close dialog");
      closingButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e)
      {
      SwingUtilities.invokeLater(new Runnable(){
      public void run()
      {
      dialog.dispose();
      }
      });
      }
      });

      JPanel panel = new JPanel(new BorderLayout());
      panel.setBorder(BorderFactory.createEmptyBorder(40,40,40,40));
      panel.add(closingButton,BorderLayout.CENTER);

      dialog.add(panel);
      dialog.setResizable(false);
      dialog.pack();
      dialog.setLocationRelativeTo(frame);
      dialog.setVisible(true);
      }
      });

      JPanel panel = new JPanel(new BorderLayout());
      panel.setBorder(BorderFactory.createEmptyBorder(40,40,40,40));
      panel.add(openingButton,BorderLayout.CENTER);

      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.add(panel);
      frame.pack();
      frame.setLocationRelativeTo(null);
      frame.setVisible(true);
      }


      private static Image createIconImage(Color color)
      {
      BufferedImage image = new BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB);
      Graphics graphics = image.getGraphics();
      graphics.setColor(color);
      graphics.fillOval(0,0,16,16);
      graphics.dispose();
      return image;
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None found.

            vbaranovsunw Vyacheslav Baranov (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: