JDK-4788660 : JOptionPane's owned by non-resizable JDialog's have wrong frame icon
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2002-12-04
  • Updated: 2003-01-17
  • Resolved: 2003-01-17
Related Reports
Relates :  
Relates :  
Description
We had a developer complain that bugid 4284610 is still reproducible in Merlin.  
I tested on windows NT with 1.4.2 build 8, and reproduced the problem.  
The resizable JDialog inherits the frame icon of the parent.  The non-resizable 
JDialog does not.  

The test below is taken from 4284610.  

In the test below, you need to supply an icon image.  I used the icon at: 
/test/java/awt/Frame/FrameIconImage/icon.gif 

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class IconBug extends JFrame {
    private static final Image APP_ICON =
        new ImageIcon("d:/java/wve/src/images/SineWave.gif").getImage();

    private static final String MSG1 =
        "<html><font size=-1>" +
        "The frame icon should be the same as<p>" +
        "the main app window icon";

    private static final String MSG2 =
        "<html><font size=-1>" +
        "What kind of frame icon does this window have?<p>" +
        "In <b>1.2.2</b> it is the same as the main app window icon,<p>" +
        "but in <b><font color=red>1.3beta</font></b> it's the default "+
        "<i>Windows waving flag</i> icon!";

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

    public IconBug() {

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        setIconImage(APP_ICON);

        final JDialog dlg1 = new JDialog(this, "A resizable JDialog", false);
        dlg1.setResizable(true);
        JButton b1 = new JButton("Click to open JOptionPane");
        b1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showMessageDialog(dlg1, MSG1);
            }
        });
        dlg1.getContentPane().add(b1);
        dlg1.pack();
        dlg1.setLocation(200,200);

        final JDialog dlg2 = new JDialog(this, "A NON-resizable JDialog", false);
        dlg2.setResizable(false);
        JButton b2 = new JButton("Click to open JOptionPane");
        b2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showMessageDialog(dlg2, MSG2);
            }
        });
        dlg2.getContentPane().add(b2);
        dlg2.pack();
        dlg2.setLocation(300,300);

        JButton b = new JButton("Click here open the JDialogs");
        b.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                dlg1.setVisible(true);
                dlg2.setVisible(true);
            }
        });

        getContentPane().add(b);
        pack();
        setVisible(true);
    }
}


Comments
EVALUATION Commit to fix in Tiger. ###@###.### 2002-12-04 Name: rpR10076 Date: 01/04/2003 It looks to be related to 4779641. Build 8 of Mantis suffered from 4779641, and that's why the bug seemed still reproducible. With the fix for 4779641 in the workspace, it work like this: - Application has its own icon - Resizable dialog has the same icon - Non-resizable dialog has no icon - Both modal Dialogs created with JOptionPane have no icons I think this is correct behaviour. ###@###.### ====================================================================== I believe the submitter is complaining that the message dialogs shown from the non-resizeable and resizeable dialogs (JOptionPane.showMessageDialog), e.g. b2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(dlg2, MSG2); } }); have the same icon as the parent frame in 1.3.1, but have no icon in 1.4 and later. ###@###.### 2003-01-06 The Windows native equivalent to JOptionPanes do not have icons either. We intend to follow the Windows LAF, and leave JOptionPanes without icons. So, the current (1.4.2) behavior is correct. I'll mark this as not reproducible, since the fix for 4779641 is already integrated into Mantis. ###@###.### 2003-01-16
16-01-2003