【发布时间】:2013-09-04 03:28:25
【问题描述】:
在普通小程序中,我使用它来将图像加载到 JLabels 中
Image back2 = getImage(getDocumentBase(), "images/blank_blue.png");
ImageIcon background2Icon = new ImageIcon(back2);
JLabel pic2 = new JLabel(background2Icon);
当我尝试使用 Java Web Start 小程序执行此操作时,什么也没有出现。
在 Java 控制台中,它这样说
basic: Loaded image: file:/C:/Users/jdfksl/Desktop/webStartTest/images/blank_blue.png
而且没有错误,但不会出现。
我在 JLabels 中加载了图像,这些 JLabels 以这种方式在 Java Web Start 中工作
BufferedImage image=null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
image = ImageIO.read(classLoader.getResourceAsStream("images/ghast_skin.png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
但是,我想要一种更短的加载图像的方式。 还有其他选择吗?
这是我的 jnlp 文件内容
<?xml version="1.0" encoding="UTF-8"?>
<jnlp href="jws_tester.jnlp">
<information>
<title>JWS tester</title>
<vendor>HTZ.</vendor>
<description>Testing with JWS</description>
<offline-allowed />
</information>
<resources>
<j2se version="1.4+"
href="http://java.sun.com/products/autodl/j2se" />
<jar href="tester.jar" main="true" />
<!-- Specify if using JNLP extensions
<extension name="SomeExtension"
href="http://some.server.com/some_extension.jnlp" />
-->
</resources>
<security>
<all-permissions/>
</security>
<applet-desc
name="JWS tester"
main-class="mather.Main"
width="900"
height="600">
</applet-desc>
</jnlp>
【问题讨论】:
-
JNLP 的内容是什么?是否已使用JaNeLA 进行验证?
-
@AndrewThompson 我运行了 JaNeLA,它用黄色表示
Content type content/unknown does not equal expected type of application/x-java-jnlp-file和红色The processing instruction target matching "[xX][mM][lL]" is not allowed。我不知道那是什么意思 -
@AndrewThompson 实际上,从 JaNeLA 的帮助中,它说
It is typical for JNLP files checked from the local file system to be of incorrect type.,所以“内容类型未知”应该没问题 -
“我不知道这意味着什么” JaNeLA 应用中有更多详细信息。 (例如点击错误)。但是,如果你回答了我的第一个问题,我可以告诉你这意味着什么..
-
@AndrewThompson 我发布了我的 JNLP 文件,这是你想要的吗?
标签: java image applet java-web-start