Swing 输入中文时会弹出小窗口的解决方法

在jre rt.jar 中的sun.awt.im.InputMethodContext类

static

{

String str = (String)AccessController.doPrivileged(new GetPropertyAction("java.awt.im.style", null));

if (str == null) {
//返回值为 below-the-spot
  Toolkit.getDefaultToolkit(); str = Toolkit.getProperty("java.awt.im.style", null);
}
//所以默认为true 就会启动 输入中文的小窗口
belowTheSpotInputRequested = "below-the-spot".equals(str);

}

我们只需要在程序启动的地方加入如下代码

System.setProperty("java.awt.im.style","on-the-spot");

就不会再弹出来了 

你可能感兴趣的:(Swing 输入中文时会弹出小窗口的解决方法)