Swing 輸入中文時會彈出小窗口的解決方法

<p>在jre rt.jar 中的sun.awt.im.InputMethodContext類</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:257496ed-78bd-43f1-b23a-f1707b8652c4" class="wlWriterEditableSmartContent"><pre class="brush: java; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 891px; height: 190px;" style=" width: 891px; height: 190px;overflow: auto;"> static { String str = (String)AccessController.doPrivileged(new GetPropertyAction(&quot;java.awt.im.style&quot;, null));java

if (str == null) {
//返回值爲 below-the-spot
  Toolkit.getDefaultToolkit(); str = Toolkit.getProperty(&quot;java.awt.im.style&quot;, null);
}
//因此默認爲true 就會啓動 輸入中文的小窗口
belowTheSpotInputRequested = &quot;below-the-spot&quot;.equals(str);

}</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>code

<p>咱們只須要在程序啓動的地方加入以下代碼</p>orm

<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:b589ffaa-0da2-40e8-8b80-52f08d71a242" class="wlWriterEditableSmartContent"><pre class="brush: java; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 517px; height: 25px;" style=" width: 517px; height: 25px;overflow: auto;"> System.setProperty(&quot;java.awt.im.style&quot;,&quot;on-the-spot&quot;);</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>ci

<p>就不會再彈出來了&#160; </p>get

相關文章
相關標籤/搜索