Forum Stats

  • 3,852,558 Users
  • 2,264,113 Discussions
  • 7,905,099 Comments

Discussions

java awt label does not display chinese

3459348
3459348 Member Posts: 1
edited Feb 26, 2018 2:02AM in Abstract Window Toolkit (AWT)

Here is the small source code:

package test;

import java.awt.*;

import java.awt.event.*;

class Test extends Frame implements WindowListener {

  public static void main(String[] args) {

    new Test();

  }

  Test() {

    super("试验");

    setLayout(new GridBagLayout());

    GridBagConstraints grid = new GridBagConstraints();

    grid.insets = new Insets(10, 10, 10, 10);

    add(new Label("输入"), grid);

    add(new TextField(20), grid);

    addWindowListener(this);

    pack();

    setVisible(true);

  }

  public void windowOpened(WindowEvent event) {}

  public void windowClosing(WindowEvent event) {System.exit(0);}

  public void windowClosed(WindowEvent event) {}

  public void windowIconified(WindowEvent event) {}

  public void windowDeiconified(WindowEvent event) {}

  public void windowActivated(WindowEvent event) {}

  public void windowDeactivated(WindowEvent event) {}

}

Here is the application:

test.png

The title in Chinese is fine, and so is the Chinese input in TextField.  But the Chinese Label is not displayed correctly.  This is using java 9.0.4 in Windows 10.  Can anyone tell me how to fix this?

This discussion has been closed.