0% found this document useful (0 votes)
68 views1 page

Java Applet Bar Chart Example

This document defines an applet called exBarChart that displays a bar chart with 4 columns of data from 1991-1994. It initializes labels and values from parameters passed to the applet, then draws the bar chart by labeling and coloring each bar based on the values for that year.

Uploaded by

Rajesh Sharma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views1 page

Java Applet Bar Chart Example

This document defines an applet called exBarChart that displays a bar chart with 4 columns of data from 1991-1994. It initializes labels and values from parameters passed to the applet, then draws the bar chart by labeling and coloring each bar based on the values for that year.

Uploaded by

Rajesh Sharma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

/* <applet code="exBarChart" height=300 width=350> <param name ="totcol" value="4"> <param name = "c1" value = "110"> <param name

= "c2" value = "150"> <param name = "c3" value = "100"> <param name = "c4" value = "170"> <param name = "lbl1" value = "1991"> <param name = "lbl2" value = "1992"> <param name = "lbl3" value = "1993"> <param name = "lbl4" value = "1994"> </applet> */ import [Link].*; import [Link].*; publicclass exBarChart extends Applet { int n=0; String label[]; intvalue[]; publicvoid init(){ try{ n = [Link](getParameter("totcol")); label = new String[n]; value = newint[n]; label[0] label[1] label[2] label[3] = = = = getParameter("lbl1"); getParameter("lbl2"); getParameter("lbl3"); getParameter("lbl4");

value[0] = [Link](getParameter("c1")); value[1] = [Link](getParameter("c2")); value[2] = [Link](getParameter("c3")); value[3] = [Link](getParameter("c4")); } catch(Exception e) {} } publicvoid paint(Graphics g){ for (int i=0;i<n ;i++ ) { [Link]([Link]); [Link](label[i],20,(i*50)+30); [Link]([Link]); [Link](50,(i*50)+10,value[i],40); [Link](" " +value[i],value[i]+50,(i*50)+30); } } }

You might also like