开发者

Deploy Applet with JNLP

开发者 https://www.devze.com 2023-01-25 02:06 出处:网络
I\'m trying to deploy an Applet with new Java JNLP specifications, but I always receive the following error by Java Plugin Console:

I'm trying to deploy an Applet with new Java JNLP specifications, but I always receive the following error by Java Plugin Console:

BadFieldException[ Il campo <jnlp><applet-desc>width presenta un valore non valido: 0,0]

This is my HTML code:

        <script>
        var attributes = { id:'signingApplet', code:'it.insielmercato.web.signing.SigningApplet' ,width:0, height:0 } ; 
        var parameters = {jnlp_href: 'signing-applet.jnlp'} ; 
        deployJava.runApplet(attributes, parameters, '1.6');
        function setClipboardText(text){
            signingApplet.setClipboardContent(text);
        }
    </script>

This is My JNLP code:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.5+" codebase="" href="">
<information>
    <title>SigningApplet</title>
    <vendor>Insielmercato S.P.A.</vendor>
</information>
<resources>
    <!-- Application Resources -->
    <j2se version="1.6+"
          href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="signing-1.0.jar" main="true" />
</resources>
<applet-desc name="Signing Applet" main-class="it.insielmercato.web.signing.SigningApplet" width="0" height="0">
</applet-desc>
 <update check="background"/>
</jnlp>

And My Applet Code:

package it.insielmercato.web.signing;

import java.applet.Applet;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;

public class SigningApplet extends App开发者_如何转开发let implements ClipboardOwner {

/**
 * 
 */
private static final long serialVersionUID = 5272223219287676996L;

private void loadAppletParameters(){

}

public void init(){
    loadAppletParameters();
}

public void setClipboardContent(String text){
    StringSelection ss = new StringSelection(text);
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    clipboard.setContents(ss, this);
}

public void lostOwnership(Clipboard clipboard, Transferable contents) {

}

public String getClipBoardContent(){
    String content = null;
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    Transferable contents = clipboard.getContents(null);
    boolean hasTransferableText = (contents != null) &&   contents.isDataFlavorSupported(DataFlavor.stringFlavor);
    if(hasTransferableText)
        try {
            content = (String)contents.getTransferData(DataFlavor.stringFlavor);
        } catch (UnsupportedFlavorException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    return content;
}

}

Where am I going wrong?


Since "presenta un valore non valido" apparently translates to "presents a non valid value" try changing the width and height from 0 to 20.

Use CSS (Cascading Style Sheets) to make the applet hidden or invisible.


Finally I resolved. There are two problems:

First, the dimension seems should be at least 1.

And second, to see the modify on my applet I have to clear Java cache from Console.

0

精彩评论

暂无评论...
验证码 换一张
取 消