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

1.1.8_003: Graphics#drawString() does not display Japanese characters.

XMLWordPrintable

    • b04
    • x86
    • windows_98, windows_nt
    • Verified



      Name: clC74495 Date: 03/30/2000


      java version "1.1.8"

      In 1.1.8_003, Graphics#drawString() cannot display a string that consists of
      only Japanese characters. This method draws each character as a simple
      rectangle, which may mean that the character is not included in the font. This
      works well in 1.1.8.

      If a string includes only alphabet characters, or if a string includes both
      alphabet and Japanese characters, drawString() of 1.1.8_003 works well.

      Please run the following sample to check this.
      (Please run "java DrawString".)

      ----------------------------------------------------------------------
      import java.awt.*;
      import java.awt.event.*;

      /**
       * DrawStringPanel draws three strings on it.
       */
      class DrawStringPanel extends Panel {
          // alphabet character string
          private static final String ALPHABET_CHARS = "ABCDE";
          // Japanese character string
          private static final String JAPANESE_CHARS =
      "\u3042\u3044\u3046\u3048\u304a";

          /**
           * paint()
           */
          public void paint(Graphics g) {
              // This works well in both 1.1.8 and 1.1.8_003.
              g.drawString(ALPHABET_CHARS, 20, 20);

              // This works well in 1.1.8.
              // In 1.1.8_003, however, this displays five simple
              // rectangles, which may mean that the characters
              // are not included in the font.
              g.drawString(JAPANESE_CHARS, 20, 40);

               // This works well in both 1.1.8 and 1.1.8_003.
              g.drawString(ALPHABET_CHARS + JAPANESE_CHARS, 20, 60);
          }
      }

      /**
       * This class is used for displaying the DrawStringPanel.
       */
      public class DrawString extends Frame implements WindowListener {

          public void windowClosed(WindowEvent e) { System.exit(0); }
          public void windowClosing(WindowEvent e) { dispose(); }

          public void windowActivated(WindowEvent e) {}
          public void windowDeactivated(WindowEvent e) {}
          public void windowDeiconified(WindowEvent e) {}
          public void windowIconified(WindowEvent e) {}
          public void windowOpened(WindowEvent e) {}

          public static void main(String args[]) {
              DrawString app = new DrawString();
              app.addWindowListener(app);

              app.setLayout(new GridLayout(1, 1));
              app.add(new DrawStringPanel());

              app.setSize(200, 200);
              app.setVisible(true);
          }
      }
      ----------------------------------------------------------------------
      (Review ID: 102895)
      ======================================================================

            duke J. Duke
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: