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

JDK1.2b2(win32) TextArea and TextField do not support non-English

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.2.0
    • 1.1.3, 1.1.4, 1.2.0
    • client-libs
    • 1.2beta3
    • x86, sparc
    • solaris_2.5.1, windows_95, windows_nt
    • Not verified



      Name: gvC48267 Date: 01/13/98


      In Japanese-Windows95 system,
      JDK1.2b2(win32)'s TextArea and TextField cannot display
      non-English language strings.

      I can input Japanese strings in TextArea and TextField correctly.
      And they are displayed correctly.
      But Japanese strings (Unicode escaped) in a source program
      are not displayed in TextArea and TextField correctly.
      Another Components(Button, etc) can be displayed correctly.
      BugID 4060931 seems a Solaris bug.
      My bug can be evaluated by the same program in the bug report.

      My test program is following.

      -----ShowUnicode.html-----
      <HTML>
      <HEAD>
      <TITLE>
      </TITLE>
      </HEAD>
      <BODY>
      <applet code="ShowUnicode.class" width="500" height="500">
      </applet>
      <HR>
      </BODY>
      </HTML>
      -----ShowUnicode.java-----
      /**
       *
       * Unicode \u8868\u793a\u30c6\u30b9\u30c8(Unicode)
       * %W% (%E%)
       *
       *
       * @version %W% %E%
       * @author Toshiki Murata
       *
       * Copyright (C) 1996 Oki Electric Industry Co.,Ltd.
       */
      import java.applet.Applet;
      import java.awt.*;

      public class ShowUnicode extends Applet {

          public void init() {
              Component parent = this;
              while (parent != null && !(parent instanceof Frame)) {
                  parent = parent.getParent();
              }
              if (parent != null) {
                  MenuBar menubar = ((Frame)parent).getMenuBar();
      Menu menu1, menu2, menu3 ;
      menu1 = new Menu("Menu");
      menu1.add(new MenuItem("Close"));
      menu2 = new Menu("Kanji(Unicode) --> \u6f22\u5b57");
      menu2.add(new MenuItem("Kanji(Unicode) --> \u6f22\u5b57"));
      menu3 = new Menu("Sub Kanji(Unicode) --> \u6f22\u5b57");
      menu3.add(new MenuItem("Kanji(Unicode) --> \u6f22\u5b57"));
      menu2.add(menu3);
      if (menubar != null) {
      menubar.add(menu1);
      menubar.add(menu2);
      } else {
      menubar = new MenuBar();
      menubar.add(menu1);
      menubar.add(menu2);
      ((Frame)parent).setMenuBar(menubar);
      }
              }

      // \u6f22\u5b57(\ub4c1\ubbfa in Unicode)
      add(new Label("Kanji(Unicode) --> \u6f22\u5b57")) ;
      add(new TextArea("Kanji(Unicode) --> \u6f22\u5b57"));
      //TextArea textArea;
      //add(textArea = new TextArea());
      //textArea.setText("Kanji(Unicode) --> \u6f22\u5b57");
      add(new TextField("Kanji(Unicode) --> \u6f22\u5b57"));
      add(new Button("Kanji(Unicode) --> \u6f22\u5b57"));
      add(new Checkbox("Kanji(Unicode) --> \u6f22\u5b57"));

      List list;
      list = new List();
      list.addItem("Kanji(Unicode) --> \u6f22\u5b57");
      list.addItem("Kanji(Unicode) --> \u6f22\u5b57");
      list.addItem("Kanji(Unicode) --> \u6f22\u5b57");
      add(list);

      Choice chooser = new Choice();
      chooser.add("Kanji(Unicode) --> \u6f22\u5b57");
      chooser.add("Kanji(Unicode) --> \u6f22\u5b57");
      chooser.add("Kanji(Unicode) --> \u6f22\u5b57");
      add(chooser);

      Canvas canvas = new ShowUnicodeCanvas("Kanji(Unicode) -->
      \u6f22\u5b57");
      canvas.setForeground(Color.red);
      canvas.setBackground(Color.white);

      add(canvas);

      Frame frame = new ShowUnicodeFrame(this);
          }

          public static void main(String[] args) {
      Frame frame = new Frame();
      frame.resize(500,500);
      ShowUnicode showUnicode = new ShowUnicode();
      frame.add(showUnicode);
      frame.show();
      showUnicode.init();
      showUnicode.start();
          }
      }

      class ShowUnicodeFrame extends Frame {
          Applet applet;
          ShowUnicodeFrame(Applet applet) {
      super("Kanji(Unicode) --> \u6f22\u5b57");

      this.applet = applet;

      setLayout(new FlowLayout());

      Menu menu1, menu2, menu3 ;
      menu1 = new Menu("Menu");
      menu1.add(new MenuItem("Close"));
      menu2 = new Menu("Kanji(Unicode) --> \u6f22\u5b57");
      menu2.add(new MenuItem("Kanji(Unicode) --> \u6f22\u5b57"));
      menu3 = new Menu("Sub Kanji(Unicode) --> \u6f22\u5b57");
      menu3.add(new MenuItem("Kanji(Unicode) --> \u6f22\u5b57"));
      menu2.add(menu3);
      MenuBar mbar = new MenuBar();
      mbar.add(menu1);
      mbar.add(menu2);
      setMenuBar(mbar);

      // \u6f22\u5b57(\ub4c1\ubbfa in Unicode)
      add(new Label("Kanji(Unicode) --> \u6f22\u5b57")) ;
      add(new TextArea("Kanji(Unicode) --> \u6f22\u5b57"));
      //TextArea textArea;
      //add(textArea = new TextArea());
      //textArea.setText("Kanji(Unicode) --> \u6f22\u5b57");
      add(new TextField("Kanji(Unicode) --> \u6f22\u5b57"));
      add(new Button("Kanji(Unicode) --> \u6f22\u5b57"));
      add(new Checkbox("Kanji(Unicode) --> \u6f22\u5b57"));

      List list;
      list = new List();
      list.addItem("Kanji(Unicode) --> \u6f22\u5b57");
      list.addItem("Kanji(Unicode) --> \u6f22\u5b57");
      list.addItem("Kanji(Unicode) --> \u6f22\u5b57");
      add(list);

      Choice chooser = new Choice();
      chooser.add("Kanji(Unicode) --> \u6f22\u5b57");
      chooser.add("Kanji(Unicode) --> \u6f22\u5b57");
      chooser.add("Kanji(Unicode) --> \u6f22\u5b57");
      add(chooser);

      Canvas canvas = new ShowUnicodeCanvas("Kanji(Unicode) -->
      \u6f22\u5b57");
      canvas.setForeground(Color.red);
      canvas.setBackground(Color.white);
      add(canvas);

      resize(500, 500);
      show();
          }

          // \u30a2\u30af\u30b7\u30e7\u30f3\u30a4\u30d9\u30f3\u30c8
          public boolean action(Event e, Object o) {

      // \u30e1\u30cb\u30e5\u30fc\u51e6\u7406
              if (e.target instanceof MenuItem) {
                  String s = (String)o;
                  if (s.equals("Close")) {
                      dispose();
      if (applet != null) {
      applet.showStatus("Kanji(Unicode) --> \u6f22\u5b57");
      }
                  }
                  return true;
      }
              return false;
          }

          // \u30cf\u30f3\u30c9\u30eb\u30a4\u30d9\u30f3\u30c8
          public boolean handleEvent(Event e) {
      if (e.id == Event.WINDOW_DESTROY) {
      // delete,
      close\u30dc\u30bf\u30f3\u304c\u62bc\u3055\u308c\u305f\u3089\u30a6\u30a3\u30f3\u3
      0c9\u30a6\u3092\u9589\u3058\u308b
      dispose();
      return true;
      }

      // return false; \u3067\u306f\u306a\u304f\u3001
      //
      \u3053\u3046\u3057\u306a\u3044\u3068\u30a2\u30af\u30b7\u30e7\u30f3\u30a4\u30d9\u
      30f3\u30c8(action(e,o))\u304c\u547c\u3070\u308c\u306a\u3044
      return super.handleEvent(e);
          }
      }

      class ShowUnicodeCanvas extends Canvas {
          String label;
          ShowUnicodeCanvas(String label) {
      this.label = label;
          }
          public void paint(Graphics g) {
      Point p = labelPoint(g);
      g.drawString(label, p.x, p.y);
          }
          Point labelPoint(Graphics g) {
      int w = size().width;
      int h = size().height;
      FontMetrics fm = g.getFontMetrics();
      int ascent = fm.getAscent();
      int labelw = fm.stringWidth(label);
      int labelh = ascent + fm.getDescent();
      int x = (w - labelw) / 2;
      int y = (h - labelh) / 2 + ascent;
      return new Point(x, y);
          }
          public Dimension minimumSize() {
      Font font = getFont();
      FontMetrics fm = getFontMetrics(font);
      int labelw = fm.stringWidth(label);
      int labelh = fm.getAscent() + fm.getDescent();
      return new Dimension(labelw, labelh);
          }
          public Dimension preferredSize() {
      Dimension d = minimumSize();
      d.width += 14;
      d.height += 10;
      return d;
          }
      }
      (Review ID: 23208)
      ======================================================================

            ehawkessunw Eric Hawkes (Inactive)
            gvanassesunw Gunter Vanasse (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: