-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.0
-
generic
-
generic
Name: boT120536 Date: 12/16/2000
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\>java -version
java version "1.3.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_01)
Java HotSpot(TM) Client VM (build 1.3.0_01, mixed mode)
In window2000, when language input system changed(from korean to japanese) ,
JTextField displays other char than input char. (ex, え(input) ==> ェィ
(displayed) )
But, TextField displays it same.( え(input) ==> え(displayed) )
<source code>
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.awt.im.*;
public class B extends JFrame implements ActionListener{
JTextField jtf;
JTextField jtfto;
public B() {
setSize(800,600);
getContentPane().setLayout(null);
JButton jb = new JButton("convert");
jb.setBackground(Color.yellow);
JButton jbback = new JButton("re-convert");
jbback.setBackground(Color.green);
JButton clearb = new JButton("clear");
clearb.setBackground(Color.cyan);
jtf = new JTextField();
jtf.setEditable(true);
try {
// if windows 98 system, "c:/winnt/Fonts/msgothic.ttf" ===>
"c:/windows/Fonts/msgothic.ttf"
jtf.setFont(Font.createFont(Font.TRUETYPE_FONT, new FileInputStream
("c:/winnt/Fonts/msgothic.ttf")).deriveFont(12f) );
System.getProperties().list(System.out);
}catch(Exception ee){System.out.println("font loading failued....");}
System.out.println(jtf.getFont().toString());
jtf.setSize(200,50);
jtf.setBounds(300,100,400,50);
jtfto = new JTextField();
jtfto.setSize(200,50);
jtfto.setBounds(300,300,400,50);
jb.addActionListener(this);
jb.setBounds(100,100,100,25);
jbback.addActionListener(this);
jbback.setBounds(100,300,100,25);
clearb.setBounds(500,450,100,100);
clearb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
jtf.setText("");
jtfto.setText("");
}
});
getContentPane().add(jb);
getContentPane().add(jbback);
getContentPane().add(jtf);
getContentPane().add(jtfto);
getContentPane().add(clearb);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
if( ae.getActionCommand().equals("convert") ) {
String inputs = jtf.getText();
try {
String outputs = "";
for(int j=0; j<inputs.length(); j++) {
outputs =
outputs.concat"@"+UnicodeForm.charToHex(inputs.charAt(j)));
}
jtfto.setText(outputs);
}catch(Exception e) {
jtfto.setText("ERROR OCCURRED !!!!!!!!1");
}
}else {
StringTokenizer stz = new StringTokenizer(jtfto.getText(),"@",false);
String reconvert = "confirm : ";
while( stz.hasMoreTokens() ) {
try {
reconvert += (char)Integer.parseInt(stz.nextToken(),16) ;
}catch(Exception ee) {jtf.setText("Error occurred !!!!!!!!!!");}
}
jtf.setText(reconvert);
}
}
public static void main(String[] ar) {
B j = new B();
}
}
import java.io.*;
public class UnicodeForm {
static public String byteToHex(byte b) {
// Returns hex String representation of byte b
char hexDigit[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
};
char[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] };
return new String(array);
}
static public String charToHex(char c) {
// Returns hex String representation of char c
byte hi = (byte) (c >>> 8);
byte lo = (byte) (c & 0xff);
return byteToHex(hi) + byteToHex(lo);
}
} // class
(Review ID: 113694)
======================================================================
- duplicates
-
JDK-4226414 RFE: Need to support multiple input method locales for Windows 2000
-
- Resolved
-