Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java awt label does not display chinese

3459348Feb 26 2018 — edited Feb 26 2018

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?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2018
Added on Feb 26 2018
0 comments
289 views