2017-09-06 248 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); 
    } 
}