I'm just beginner of Java.
I'm trying to unicode (display) correctly Myanmar texts on Java GUI ( Swing/Awt ).
I have four TrueType fonts which support Myanmar unicode texts. There are Myanmar3, Padauk, Tharlon, Myanmar Text ( Window 8 built-in ).
You may need the fonts before the code. Google the fonts, please.
Each of the fonts display on Java GUI differently and incorrectly.
Here is the code for GUI Label displaying myanmar texts:
++++++++++++++++++++++++
package javaapplication1;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class CusFrom {
private static void createAndShowGUI() {
JFrame frame = new JFrame("Hello World Swing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String s = "\u1015\u102F \u103C\u1015\u102F";
JLabel label = new JLabel(s);
label.setFont(new java.awt.Font("Myanmar3", 0, 20));// font insert here, Myanmar Text, Padauk, Myanmar3, Tharlon
frame.getContentPane().add(label);
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
++++++++++++++++++++++++
Outputs vary. See the pictures:
Myanmar3 IMG
Padauk IMG
Tharlon IMG
Myanmar Text IMG
What is the correct form?
(on notepad)
Well, next is the code for GUI Textfield inputting Myanmar texts:
++++++++++++++++++++++++
package javaapplication1;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class XusForm {
private static void createAndShowGUI() {
JFrame frame = new JFrame("Frame Title");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextField textfield = new JTextField();
textfield.setFont(new java.awt.Font("Myanmar3", 0, 20));
frame.getContentPane().add(textfield);
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
++++++++++++++++++++++++
Outputs vary when I input keys( unicode text ) on keyboards.
Myanmar Text Output IMG
Padauk Output IMG
Myanmar3 Output IMG
Tharlon Output IMG
Those fonts work well on Linux when opening text files with Text Editor application.
My Question is how to unicode Myanmar texts on Java GUI. Do I need additional codes left to display well? Or Does Java still have errors? The fonts display well on Web Application (HTML, CSS) but I'm not sure about displaying on Java Web Application.