我試圖在JTextArea中打印unicode。我已經將它打印到控制檯上,但是當我嘗試將它打印到textarea時,我得到了所有兩個字節的unicode字符的框。任何幫助將非常感激。在Java JTextArea中顯示Unicode
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
}
}
德文郡,完美!雖然我沒有DejaVu Sans,但我確實有Euphemia,並立即修復它。非常感謝! – JimmyButterfly 2010-07-16 16:43:13