【发布时间】:2018-02-14 15:37:37
【问题描述】:
我有一个使用 JXLayer 和 pbjar-Framework 的带有可缩放 UI 的 java swing 项目。 JTextComponents 存在一个问题,该问题已通过 TransformUI.java 中的以下方法修复:
/**
* {@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("i18n", 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个案例:
- java
- javaws [网址]
- javaws [本地文件]
- 浏览器
使用 oracle java 8u141、32 或 64 位、Windows 7 64 位、linux debian 7 64 位、firefox 进行测试 java
如果我将客户端称为 java 应用程序,则修复工作正常
javaws [url]
此调用在 linux 和 windows 中运行良好。 但是在旧版本的 jnlp 文件中,我们使用扩展来包含 3rd-party JAR,在 Windows 中,这个调用会工作一次,直到我删除缓存的文件
javaws [本地文件]
没用
浏览器
没用
有什么建议为什么系统属性不起作用?
【问题讨论】:
标签: java swing java-web-start java-security