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

Frame.setTitle(null) - inconsisten behaviour

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.2
    • 1.4.0
    • client-libs
    • mantis
    • sparc
    • solaris_2.5
    • Verified



      Name: apR10100 Date: 02/06/2002



      Methods:

      Frame.setTitle incorrectly and
      inconsistently handles null as parameter.

      JDK1.4 spec states:

      ------------------
      public String getTitle()
      Gets the title of the frame. The title is displayed in the frame's border.

      Returns:
      the title of this frame, or an empty string ("") if this frame doesn't have a title.

      ...

      public void setTitle(String title)
      Sets the title for this frame to the specified string.
      ...
      --------------------------------------------------------------------------------

      Handling of null is not specified and should be default (throwing NPE).
      getTitle should never return null - it should be some String, possibly
      empty.

      However jdk1.4 takes null as parameter for setTitle without any
      exception and returns null from getTitle() after that:

      --------- TestTitle.java
      import java.awt.*;

      public class TestTitle {

        public static void main (String [] args) {
          
              Frame f = new Frame();
              f.show();
          
              try {
                  f.setTitle(null);
                  System.out.println("Unexpectedly set title to: '"+f.getTitle()+"'");
              } catch (NullPointerException npe) {
                 npe.printStackTrace();
              } finally {
                  f.dispose();
              }
          }

      --------- Output
      3,~/tmp;
      /set/java/jdk1.4/solaris/bin/java TestTitle
      Unexpectedly set title to: 'null'
      3,~/tmp;
      ---------

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

            son Oleg Sukhodolsky (Inactive)
            avpsunw Avp Avp (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: