Tôi đang cố gắng in unicode trong JTextArea. Tôi đã nhận được nó để in tốt để giao diện điều khiển nhưng khi tôi cố gắng in nó vào textarea, tôi nhận được hộp cho tất cả các ký tự unicode hai byte. Bất kì sự trợ giúp nào đều được đánh giá cao.Hiển thị Unicode trong Java JTextArea
package edu.afit.jieddo;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JTextAreaDemo extends JFrame {
StringBuffer m = new StringBuffer("\u14c7 \u14c4 \u1557 \u00d6");
StringBuffer m2 =new StringBuffer(" means one.");
String message = m.append(m2).toString();
public JTextAreaDemo() {
super("\u14c7 \u14c4 \u1557 \u00d6");
java.awt.Font font = new java.awt.Font("Arial Unicode MS", java.awt.Font.PLAIN, 18);
JTextArea textArea = new JTextArea(message);
textArea.setFont(font);
java.awt.Container container=this.getContentPane();
container.add(textArea);
System.out.println(textArea.getFont().getFamily());// testing output in the command line
}
public static void main(String[] args) {
JTextAreaDemo frame = new JTextAreaDemo();
frame.setFont(new Font("Arial Unicode MS",Font.ITALIC,11));
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
System.out.println("\u14c7 \u14c4 \u1557 \u00d6");
System.out.println(frame.getFont().getFamily());//testing output in the command line
}
}
Devon, hoàn hảo! Trong khi tôi không có DejaVu Sans, tôi đã có Euphemia và nó đã sửa nó ngay lập tức. Cám ơn rất nhiều! – JimmyButterfly