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

behavior of java.awt.Font.Font(String ...) does not correspond to documentation

XMLWordPrintable

    • 2d
    • beta
    • sparc
    • solaris_2.6, solaris_7



      Name: dsR10051 Date: 11/16/2000



      The documentation for constructor
      java.awt.Font.Font(String name, int style, int size)
      "
           ...
           * @param name the font name. This can be a logical font name or a
           * font face name. A logical name must be either: Dialog, DialogInput,
           * Monospaced, Serif, SansSerif, or Symbol. If <code>name</code> is
                                                       ^^^^^^^^^^^^^^^^^^^^^^^
           * <code>null</code>, the <code>name</code> of the new
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           * <code>Font</code> is set to Default.
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           ...
      "

      But the example below demonstrates that the name of new font
      is set to Dialog.
      Under JDK1.3 the name of the font in this case is set to Default
      that corresponds to doc.

      Here is a minimized test:
      import java.awt.Font;

      public class FontTest01 {

          public static void main(String[] args) {
              Font font = new Font((String) null, Font.PLAIN, 12);
              System.out.println("Font created:");
              System.out.println(font);
              if(font.getName().equals("Default")) {
                  System.out.println("OKAY");
              } else {
                  System.out.println("FAILED: Font name is " + font.getName());
                  System.out.println(" Should be Default");
              }
              System.exit(0);
          }
      }
      --- Output ---
      %java -version
      java version "1.4.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b40)
      Java HotSpot(TM) Client VM (build 1.4beta-B40, mixed mode)
      %java FontTest01
      Font created:
      java.awt.Font[family=dialog,name=Dialog,style=plain,size=12]
      FAILED: Font name is Dialog
              Should be Default
      %/set/java/jdk1.3/solaris/bin/java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)
      %/set/java/jdk1.3/solaris/bin/java FontTest01
      Font created:
      java.awt.Font[family=Arial,name=Default,style=plain,size=12]
      OKAY

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

            dougfelt Doug Felt (Inactive)
            sdasunw Sda Sda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: