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

JOptionPane setTitle doesn't work

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.5
    • client-libs



      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.

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

            amfowler Anne Fowler (Inactive)
            miflemi Mick Fleming
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: