中文(繁体) - 新快 中文(繁体)- 畅捷中文(繁体)- 快速中文(繁体)- 拼音中文(繁体)- 新拼音中文(繁体)- 新畅捷如果我在 Java 应用程序中选择这些输入法之一并将字符宽度设置为半角(单字节字符模式),我可以在 JTextField 中成功输入文本.但是,如果应用程序显示某些对话框(例如 JOptionPane)或弹出窗口,输入法字符宽度将自动更改为全角(双字节字符模式).之后,用户必须手动切换到半角字符.我可以使用 Java 类InputContext"以编程方式打开或关闭输入法,但我无法控制输入法是否设置为全角/半角(单字节/双字节)字符模式.我想也许可以从 Windows 输入法设置中禁用它,但是没有与自动切换字符宽度相关的选项.问题是:有没有办法处理(禁用)这种自动切换?以下是使用上述输入法进行测试的示例代码:public class Example 实现 ActionListener {JFrame f = new JFrame("pasod");JTextField txt = new JTextField();Button btn = new Button("Locale");公共示例(){JPanel 面板 = new JPanel();panel.setLayout(new GridLayout());btn.addActionListener(this);panel.add(btn);panel.add(txt);f.添加(面板);f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.pack();f.setSize(800, 100);f.setVisible(true);}公共静态无效主(字符串 [] args){新的例子();}公共无效动作执行(ActionEvent arg0){JOptionPane.showMessageDialog(btn, "Neso", "Neso",JOptionPane.INFORMATION_MESSAGE);}}谢谢. 解决方案 我做了一个简单的测试:我打开IE,选择一个标签页,在地址栏设置中文输入法为半宽.然后单击另一个选项卡,IME 自动更改为全宽.所以我认为它与 Java 没有任何关系.这是 Windows 的行为.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) - ChangJieChinese (Traditional) - Quick Chinese (Traditional) - PhoneticChinese (Traditional) - New Phonetic Chinese (Traditional) - New ChangJieIf 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. 这篇关于通过 Java 中的 Windows 7 输入法自动切换字符宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 11-01 11:37