Muh*_*ooq 4 java swing jtextpane internationalization
如何在一个?中显示单个Urdu字符JTextPane?我已将英文字符翻译成乌尔都语字符.但我找不到任何方法将这些字符正确显示到我的文本组件中.
我的目标是:
JTextPane)中显示它.我已经完成了第1步和第2步,但无法完成最后一步.
至 3- display it in my text component that is JTextPane

project以纯UTF-8编码
import javax.swing.*;
import java.awt.*;
public class Example {
private JFrame frameA = new JFrame("Example");
private JTextArea textA = new JTextArea(10, 5);
public Example() {
frameA.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
textA.setForeground(new Color(255, 150, 150));
textA.setText("Peace be upon you (Hello) - ?????? ????? " + "\n");
textA.append("Peace be upon you too (Hello) - ? ????? ?????? " + "\n");
textA.append("I am happy to meet you - ?? ?? ?? ?? ???? ????" + "\n");
textA.append("Do you speak English? - ??? ?? ??????? ????? ????" + "\n");
frameA.add(textA);
frameA.pack();
frameA.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Example exam = new Example();
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:
谢谢Stas
我把它放到了JTextArea
添加了JTextPane示例
import javax.swing.*;
import java.awt.*;
public class Example {
private JFrame frameA = new JFrame("Example");
private JTextPane textP = new JTextPane();
public Example() {
frameA.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
textP.setForeground(new Color(255, 150, 150));
textP.setText("Peace be upon you (Hello) - ?????? ????? " + "\n"
+"Peace be upon you too (Hello) - ? ????? ?????? " + "\n"
+"I am happy to meet you - ?? ?? ?? ?? ???? ????" + "\n"
+"Do you speak English? - ??? ?? ??????? ????? ????" + "\n");
frameA.add(textP);
frameA.pack();
frameA.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Example exam = new Example();
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1415 次 |
| 最近记录: |