JDK-4121055 : JOptionPane setTitle doesn't work
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.5
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_95
  • CPU: x86
  • Submitted: 1998-03-19
  • Updated: 1998-03-19
  • Resolved: 1998-03-19
Related Reports
Duplicate :  
Description

Name: mf23781			Date: 03/19/98


import java.awt.event.*;
import java.awt.*;
import java.util.*;
import com.sun.java.swing.*;
import com.sun.java.swing.event.*;
import com.sun.java.swing.table.*;


/**
Recreate JOptionPane problems.<br>
1.Title not updated.
<br>
2.Size not correct.
**/

public class Test2 extends JPanel
{

static JFrame frame;


/**
Ctor.
**/
public Test2 ()
throws Exception
{
        JButton shorty = new JButton("short");
        add(shorty);
        shorty.addActionListener( new ActionListener()
        {
            public void actionPerformed(ActionEvent ev)
            {
                JOptionPane.showMessageDialog(frame, // parent
                       "Short message", // message
                       "Short title",   // title
                       JOptionPane.INFORMATION_MESSAGE ); // message type
            }
        }
        );
        JButton longy = new JButton("long");
        add(longy);
        longy.addActionListener( new ActionListener()
        {
            public void actionPerformed(ActionEvent ev)
            {
                JOptionPane.showMessageDialog(frame, // parent
                       "This is a long message that will get truncated because it does not fit.", // message
                       "Long title",   // title
                       JOptionPane.INFORMATION_MESSAGE ); // message type
            }
        }
        );
}



/**
MAIN
**/
public static void main(String args[])
    throws Exception
{
    WindowListener l = new WindowAdapter()
    {
        public void windowClosing(WindowEvent e)
        {
            System.exit(0);
        }
    };
	frame = new JFrame ("Test Visual");
    frame.addWindowListener(l);
    frame.getContentPane().setLayout(new BorderLayout());
    Test2 gui = new Test2();
    frame.getContentPane().add("Center", gui);
	frame.setSize(800, 600);
    frame.pack();
    frame.setVisible(true);
}


}

If you run the test case above and click on the "short" button and
then "long" then you should clearly see that the title of the dialog 
remains unchanged.

This test case was designed to show a problem with the dialog itself
not being resized but this could not be reproduced here.

======================================================================

Comments
EVALUATION [aim 3/19/98] This is actually a win32 AWT bug where setTitle isn't working on modal dialogs.
11-06-2004