java中字符类型输入法,在Java的Windows 7的输入法字符宽度自动来回切换

I have a couple of input methods for writing (Traditional Chinese) Taiwanese that come with the Windows 7. Also, all of the input methods have an option to switch the character width (single byte/double byte characters).

Chinese (Traditional) - New Quick

Chinese (Traditional) - ChangJie

Chinese (Traditional) - Quick

Chinese (Traditional) - Phonetic

Chinese (Traditional) - New Phonetic

Chinese (Traditional) - New ChangJie

If I select one of these input methods in Java application and set the character width to half-width(single byte character mode) i can successfully input text in JTextField. But, if the application displays some dialog box (e.g. JOptionPane) or pop up window, the input method character width will automatically change to full-width(double byte character mode). After that, the user must manually toggle to half-width characters.

I can programmatically switch on or off the input method using the Java class "InputContext", but i can't control if the input method is set to full-width/half-width (single/double byte) character mode.

I thought maybe it could be disabled from the Windows input method settings, but there was no option related to automatic switching of the character width.

The question is: Is there a way to handle (disable) this automatic toggling ?

Here is an example code to test this with the above input methods:

public class Example implements ActionListener {

JFrame f = new JFrame("pasod");

JTextField txt = new JTextField();

Button btn = new Button("Locale");

public Example() {

JPanel panel = new JPanel();

panel.setLayout(new GridLayout());

btn.addActionListener(this);

panel.add(btn);

panel.add(txt);

f.add(panel);

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.pack();

f.setSize(800, 100);

f.setVisible(true);

}

public static void main(String[] args) {

new Example();

}

public void actionPerformed(ActionEvent arg0) {

JOptionPane.showMessageDialog(btn, "Neso", "Neso",

JOptionPane.INFORMATION_MESSAGE);

}

}

Thanks.

解决方案

I did a simple test:

I opened IE, selected a tab, and at the address bar, set Chinese IME to be half width. Then click another tab, the IME change to full width automatically.

So I don't think it had anything to do with Java. It's a Windows behavior.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值