If you want to display Unicode-compliant Vietnamese in desktop applications, you need to do it on Swing components. Console does not support display of Unicode.
If you run your program on a Java virtual machine (JVM) prior to 5.0, you would need to modify the font.properties file (Windows | Linux) under the jre/lib directory to enable display of Vietnamese characters. Java 5.0 (codename Tiger), Windows version, has the support built in.
To display Vietnamese, or Unicode in general, on the title bar, you need Java 1.4.2 at least. And you may also need to choose Unicode font, whose selection is controlled by the underlying operating system. For instance, for Windows, font for Title Bar can be changed via the Advanced Appearance properties of Display applet in Control Panel.
/* * Notepad.java * * Simple editor for Vietnamese */ import javax.swing.*; //import net.sourceforge.vietpad.inputmethod.*; public class Notepad extends JFrame { /** Creates new form Notepad */ public Notepad() { JScrollPane jScrollPane = new JScrollPane(); JTextArea jTextArea = new JTextArea(); // jTextArea.addKeyListener(new VietKeyListener(jTextArea)); // VietKeyListener.setSmartMark(true); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setTitle("Tiếng Việt"); jTextArea.setText("Áo nàng vàng anh về yêu hoa cúc\nÁo nàng xanh anh mến lá sân trường"); jScrollPane.setViewportView(jTextArea); getContentPane().add(jScrollPane, java.awt.BorderLayout.CENTER); pack(); setVisible(true); JOptionPane.showMessageDialog(null, "Thử nghiệm Tiếng Việt", "Tiếng Việt", JOptionPane.INFORMATION_MESSAGE); } /** * @param args the command line arguments */ public static void main(String args[]) { new Notepad(); } }
Save the file in UTF-8 format and execute the following commands:
javac -encoding utf8 Notepad.java java Notepad
Note: You can add the capability to type Vietnamese by including
VietKeyInput.jar
in the classpath when compiling and executing the program after uncommenting the
commented block.