2017-09-06 260 views
1

我有一個java swing項目,使用JXLayer和pbjar-Framework的可縮放UI。有與JTextComponents一個問題是在TransformUI.java固定用以下方法:java webstart忽略System.getProperties()或Syste.setProperties()被忽略

/** 
* {@link JTextComponent} and its descendants have some caret position 
* problems when used inside a transformed {@link JXLayer}. When you plan to 
* use {@link JTextComponent}(s) inside the hierarchy of a transformed 
* {@link JXLayer}, call this method in an early stage, before instantiating 
* any {@link JTextComponent} . 
* <p> 
* It executes the following method: 
* 
* <pre> 
* System.setProperty(&quot;i18n&quot;, Boolean.TRUE.toString()); 
* </pre> 
* 
* As a result, a {@link GlyphPainter} will be selected that uses floating 
* point instead of fixed point calculations. 
* </p> 
*/ 
public static void prepareForJTextComponent() { 
    System.setProperty("i18n", Boolean.TRUE.toString()); 
} 

所有的JAR文件都簽有有效的證書,以及JNLP看起來像

<?xml version="1.0" encoding="utf-8"?> 
<jnlp spec="7.0+" codebase="https://__HOST_IP____HOST_HTTPS_PORT__/test" 
    href="client/1024.jnlp"> 
    <information> 
    <offline-allowed /> 
    </information> 
    <security> 
    <all-permissions /> 
    </security> 
    <resources> 
    <j2se version="1.8+" java-vm-args="-Xmx512M" /> 
    <jar href="client.jar" /> 
    ... more JARs 
    </resources> 
    <application-desc main-class="de.test.Frame"> 
    <argument>__HOST_IP__</argument> 
    </application-desc> 
</jnlp> 

的client.jar中MANIFEST.MF包含以下

... 
Permissions: all-permissions 
Codebase: * 
Trusted-Only: false 
Trusted-Library: false 
... 

因爲javaws的僅接受安全性能我在主類調用

static 
{ 
    TransformUI.prepareForJTextComponent(); 
} 

問題是,如果我使用每個瀏覽器的Java webstart,則JTextComponent的修復無法正常工作。

對於Java在webstart我測試4箱子:

  1. 的java
  2. javaws的[網址]
  3. javaws的[本地文件]
  4. 瀏覽器使用Oracle的java 8u141

測試, 32或64位,Windows 7的64位,Linux的Debian 7 64位,火狐 java

如果我調用客戶端的Java應用程序的修復工作正常

javaws的[URL]

此調用工作在Linux和Windows的罰款。 但在舊版本我們使用擴展到包括第三方JAR文件的JNLP文件此調用工作一次,直到我刪除緩存文件

的javaws [本地文件]

做的和Windows不行

瀏覽器

不起作用

任何建議,爲什麼SY幹屬性不起作用?

在javax.swing.text.AbstractDocument.AbstractDocument(內容,AttributeContext)的SystemProperty「國際化」

回答

0

是readed:

... 
if (defaultI18NProperty == null) { 
    // determine default setting for i18n support 
    String o = java.security.AccessController.doPrivileged(
    new java.security.PrivilegedAction<String>() { 
     public String run() { 
     return System.getProperty(I18NProperty); 
     } 
    } 
); 
    if (o != null) { 
    defaultI18NProperty = Boolean.valueOf(o); 
    } else { 
    defaultI18NProperty = Boolean.FALSE; 
    } 
} 
putProperty(I18NProperty, defaultI18NProperty); 
.... 

在我的案例屬性應該設置始終爲「真」,所以我用我自己的JTextField-class:

class MyTextField extends JTextField { 
    MyTextField() { 
    super(); 
    Document doc = new PlainDocument(); 
    doc.putProperty("i18n", Boolean.TRUE); 
    this.setDocument(doc); 
    } 
}