JDK-8007214 : [macosx] Wrong icon in modal alerts created using JOptionPane
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7u9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2013-01-30
  • Updated: 2013-05-08
  • Resolved: 2013-05-08
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 8
8Resolved
Related Reports
Cloners :  
Cloners :  
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
Wrong icon in modal alerts created using JOptionPane. If creating a modal dialog using JOptionPane and using the message types: warning, information, question or error. Then the icon used is a folder icon and not a icon representing applications. When using information or question message types, the problem is acute as only the folder icon is used

REGRESSION.  Regression from Apple's Java 6uX

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
a) Launch the attached code snipped and look at the icons used in the modal alerts displayed.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Application icons used in modal alerts as background for modal dialog alert icon
ACTUAL -
Folder icons used in modal alerts as background for modal dialog alert icon

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.Point;

import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;


public class MAlertIconBugReport {
  private static String messageTypeToString(final int messageType) {
    switch (messageType) {
      case JOptionPane.ERROR_MESSAGE: return "Error message";
      case JOptionPane.INFORMATION_MESSAGE: return "Information message";
      case JOptionPane.WARNING_MESSAGE: return "Warning message";
      case JOptionPane.QUESTION_MESSAGE: return "Question message";
      case JOptionPane.PLAIN_MESSAGE: return "Plain message";
      
      default: return "Unknown message type: " + messageType;
    }
  }
  
  /**
   * Offset of placing of modal dialogs
   */
  private static int offset = 0;
  
  public static void main(final String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        for (final Integer messageType : new Integer[] {JOptionPane.ERROR_MESSAGE, JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE, JOptionPane.QUESTION_MESSAGE, JOptionPane.PLAIN_MESSAGE}) {
          /**
           * Need to put the modal dialog creation into a <code>Runnable</code> to
           * prevent the <code>setVisible</code> call from blocking the <code>for</code>
           * loop
           */
          SwingUtilities.invokeLater(new Runnable() {
            public void run() {
              final JOptionPane optionPane = new JOptionPane(messageTypeToString(messageType), messageType);
              
              final JDialog dialog = optionPane.createDialog("Hello world!");
              
              dialog.pack();
              dialog.setLocationRelativeTo(null);
              
              /**
               * Nudge the position of the modal dialog to make the other
               * modal dialogs visible
               */
              final Point location = dialog.getLocation();
              dialog.setLocation(location.x + offset, location.y + offset);
              offset += 25;
              
              dialog.setVisible(true);
            }
          });
        }
      }
    });
  }
}

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