Im still trying to figure this applet HTML code out, I think I have tried everything that I have googled but with no results.
My HTML code
MY JAVA Source code
Okay so I did watch some youtube videos and one did point me to the LAUNCH.HTML file (after building and compiling) which works flawlessly. But the assignment specfically says to create an HTML file. And the Launch file is located in the DIST folder of the project but what I have learned from my reading and google to get the applet to work in a webpage the HTML file has to be in the same folder as the class file. When I first created the HTML file I saved it to the SRC folder, and it automatically created the CLASS folder HTML file.
The error I recieve from opening in browser is:
NoClassDefFoundError
NewPieChartJApplet(Wrong name: piechartexample/NewPieChartJApplet)
But this file in Netbeans compile and builds fine (cannot find Main class to run which I know I dont have a main class since its an applet).
The file location of the Class file and the HTML file for opening is:
C:\Users\T-Ali\Desktop\SHawnas school\prg421\PieChart\PieChartExample\build\classes\piechartexample
Please point me in the right direction?
My HTML code
<html> <title>Maine Statistics Pie Chart </title> <body> <!-- <script> var attributes = { code: "piechartexample.NewPieChartJApplet", archive: "PieChartExample.jar", width: 300, height: 300 }; deployJava.runApplet(attributes, parameters, version); </script>--> <!--<applet code="NewPieChartJApplet.class" width="400" height="500"> </applet>--> <applet code=NewPieChartJApplet.class width=300 height=300> Java not up to date Please visit java.com to update your Java </applet> </body> </html>
MY JAVA Source code
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package piechartexample; import java.awt.*; import javax.swing.*; /** * * @author T-Ali */ public class NewPieChartJApplet extends JApplet { int Assault, Rape, Burglary, larcenyTheft, vehicleTheft, total; // statistics to enter float percMur, percRape, PercBurg, percLTheft, percVTheft; // percentages //Create the outer circle of the pie chart /** * * @param g */ @Override public void paint(Graphics g) { Graphics2D g2d = (Graphics2D)g; g2d.setColor(Color.BLACK); //outside line of circle int x = 0, y = 0, w = 200, h= 200; //defines size int startPosistion, degrees; //will be used to draw pie slice //define the numbers to go with the crime Assault = 848; Rape = 393; Burglary = 7854; larcenyTheft = 24877; vehicleTheft = 1075; //calculate percentages total = Assault + Rape + Burglary + larcenyTheft + vehicleTheft ; percMur = (Assault * 100.0f) / total; percRape =(Rape * 100.0f) / total; PercBurg =(Burglary * 100.0f) / total; percLTheft =(larcenyTheft * 100.0f) / total; percVTheft = (vehicleTheft * 100.0f) / total; /* * Used an example found * http://mainline.brynmawr.edu/Courses/cs110/fall2003/Applets/PieChart/PieChart.html * * * * */ //display pie chart startPosistion = 0; degrees =(int)(percMur * 360/100); g.setColor(Color.RED); g.fillArc(x, y, w, h, startPosistion, degrees); startPosistion = degrees; degrees =(int)(percRape * 360/100); g.setColor(Color.YELLOW); g.fillArc(x, y, w, h, startPosistion, degrees); startPosistion = startPosistion + degrees; degrees =(int)(PercBurg * 360/100); g.setColor(Color.BLUE); g.fillArc(x, y, w, h, startPosistion, degrees); startPosistion = startPosistion + degrees; degrees =(int)(percLTheft * 360/100); g.setColor(Color.GREEN); g.fillArc(x, y, w, h, startPosistion, degrees); startPosistion = startPosistion + degrees; degrees =(int)(percVTheft * 360/100); g.setColor(Color.ORANGE); g.fillArc(x, y, w, h, startPosistion, degrees); } /** * @param args the command line arguments */ }
Okay so I did watch some youtube videos and one did point me to the LAUNCH.HTML file (after building and compiling) which works flawlessly. But the assignment specfically says to create an HTML file. And the Launch file is located in the DIST folder of the project but what I have learned from my reading and google to get the applet to work in a webpage the HTML file has to be in the same folder as the class file. When I first created the HTML file I saved it to the SRC folder, and it automatically created the CLASS folder HTML file.
The error I recieve from opening in browser is:
NoClassDefFoundError
NewPieChartJApplet(Wrong name: piechartexample/NewPieChartJApplet)
But this file in Netbeans compile and builds fine (cannot find Main class to run which I know I dont have a main class since its an applet).
The file location of the Class file and the HTML file for opening is:
C:\Users\T-Ali\Desktop\SHawnas school\prg421\PieChart\PieChartExample\build\classes\piechartexample
Please point me in the right direction?