Java 在HTML中显示小程序

Java 在HTML中显示小程序,java,html,applet,Java,Html,Applet,我在编写java小程序并将其与html文件链接时遇到问题 JavaApplet是关于绘制一个饼图的3个值:销售、会员和添加。java小程序的代码: import java.awt.*; import javax.swing.*; import javax.swing.border.*; /** * Class AppDemo - write a description of the class here * * @author (your name) * @version (a ver

我在编写java小程序并将其与html文件链接时遇到问题

JavaApplet是关于绘制一个饼图的3个值:销售、会员和添加。java小程序的代码:

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

/**
 * Class AppDemo - write a description of the class here
 *
 * @author (your name)
 * @version (a version number)
 */
public class AppDemo extends JApplet
{
    public void init()
    {
        Container appC = getContentPane();

        MyPanel myp = new MyPanel() ;
        myp.setBorder(new EtchedBorder() ) ;
        myp.setBackground(Color.red);
        appC.add(myp);
    }
}


class MyPanel extends JPanel {
    public void paint(Graphics g)
    {
        g.setFont(  new Font("Verdana", Font.BOLD , 18) ) ;
        g.setColor(Color.green);
        g.drawString("HELLO WORLD", 20, 20);
        g.fillArc( 20, 50, 200, 200 , 0 , 90 ) ;
        g.setColor(  new Color(255, 128, 64) ) ;
        g.fillArc( 20, 50, 200, 200 , 90 , 40 ) ;
        g.setColor(  Color.pink ) ;
        g.fillArc( 20, 50, 200, 200 , 130 , 230 ) ;
    }
}
现在我要取出第一片。。将以下内容仅添加到fillArc方法的第一个参数(x坐标)

(int) Math.round(Math.cos(put_first_value_here/360.0*Math.PI)*20)
-((int) Math.round(Math.sin(put_first_value_here/360.0*Math.PI)*20))
将以下内容仅添加到fillArc方法的第二个参数(y坐标)

(int) Math.round(Math.cos(put_first_value_here/360.0*Math.PI)*20)
-((int) Math.round(Math.sin(put_first_value_here/360.0*Math.PI)*20))
其中,first_值是第一条圆弧的角度

和html文件:

<APPLET CODE="AppDemo.class" CODEBASE="." WIDTH=500 HEIGHT=500>
<param name=adds value=1100 />
<param name=memberships value=300/>
<param name=sales value=1000/>
</APPLET>

html文件的结尾

他们告诉我使用构造函数来获取值,但我不知道怎么做,也不明白为什么要使用它


提前感谢谷歌提供的教程。。e、 g


阅读、理解、适应、测试=>交作业

如果我理解正确,您希望从小程序中访问
标记中包含的值。小程序可以通过该方法访问这些参数。通常在
init()
方法中访问这些值:

public class AppDemo extends JApplet
{
    public void init()
    {
        String adds = getParameter("adds");
        String memberships = getParameter("memberships");
        String sales = getParameter("sales");

        // The rest of your init() code...
    }
}

对不起,我的编辑失败了。