开发者

calling functions from local Java/java applet classes on an HTML page

开发者 https://www.devze.com 2023-02-19 20:20 出处:网络
I need help with calling methods from within a class of a Java or a Java applet .jar file locally stored.The idea behind using HTML as interface is that I want to make a quick good looking GUI using j

I need help with calling methods from within a class of a Java or a Java applet .jar file locally stored. The idea behind using HTML as interface is that I want to make a quick good looking GUI using jQuery and link it to other classes for my application.

A basic java applet:


package appletHW;

import java.applet.Applet;
import javax.swing.*;

public class HWapplet extends Applet {

    static JFrame frame;
    /**
     * @param args
     */
      public void init() {

        System.out.println("Hello world!");

        JOptionPane.showMessageDialog(frame,
                "Egg开发者_C百科s are not supposed to be green.");

        }
}

I hope nothing's wrong with the above code. I am new to all of this! :) I created a jar file of the above class named as aHW.jar

A HTML page for my interface:


<head>
<title>INTERFACE</title>
</head>

<body>

<object     
classid="java:appletHW.HWapplet.class"     
type="application/x-java-applet"     
archive="aHW.jar"> 

</object>
<!--not sure of the above code... -->
&nbsp;<form action="">
<input type="button" value="a" onclick="init()">
</BR>
</BR>
</BR>
<input type="button" value="b">
</BR>
</BR>
</BR>
<input type="button" value="c">
</form>
</body>

Could someone please help me with the above sample codes? I am new to all this and I would really appreciate some hand holding guidance on accomplishing the same.

Regards, Archit


For tips & examples, see Java/Javascript interaction - Real's HowTo.

0

精彩评论

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

关注公众号