hello ... iam having problem writing java applet and link it with html file
java applet is about drawing a pie chart 3 values sales, membership and adds. the code for java applet :
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 ) ;
}
}
now i want o take out the first slice.. add the following to the first parameter only (the x coordinate) of the fillArc method
(int) Math.round(Math.cos(put_first_value_here/360.0*Math.PI)*20)
add the following to the second parameter only (the y coordinate) of the fillArc method
-((int) Math.round(Math.sin(put_first_value_here/360.0*Math.PI)*20))
where first_value is the angle of the first arc
and the html file :
<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>
end of html file
they told me to use constructor to get the values but i don't know how to do it and i didn't understand why i should use it
thanks in advance