| | |
Barchart
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 28
Reputation:
Solved Threads: 0
i have a problem in getting the required display in barchart
my intended display is
year91 -------------- 110
but i get a display as
year91 -------------- year91
can anyone please let me know what is wrong in my html file or java code.
my intended display is
year91 -------------- 110
but i get a display as
year91 -------------- year91
can anyone please let me know what is wrong in my html file or java code.
Java Syntax (Toggle Plain Text)
import java.awt.*; import java.applet.*; public class BarChart extends Applet { int n =0; String label[]; int value[]; String EndLabel[]; @Override public void init() { try { n= Integer.parseInt(getParameter("columns")); label = new String[n]; value = new int[n]; EndLabel = new String[n]; label[0] = getParameter("label1"); label[1] = getParameter("label2"); label[2] = getParameter("label3"); label[3] = getParameter("label4"); value[0] = Integer.parseInt(getParameter("c1")); value[1] = Integer.parseInt(getParameter("c2")); value[2] = Integer.parseInt(getParameter("c3")); value[3] = Integer.parseInt(getParameter("c4")); EndLabel[0] = getParameter("Label1"); EndLabel[1] = getParameter("Label2"); EndLabel[2] = getParameter("Label3"); EndLabel[3] = getParameter("Label4"); } catch(NumberFormatException e) { } } @Override public void paint(Graphics g) { for(int i=0;i<n;i++) { g.setColor(Color.red); g.drawString(label[i], 20, i*50+30); g.fillRect(60, i*50+10, value[i], 40); g.drawString( EndLabel[i],60+value[i]+10, i*50+30); } } } <HTML> <APPLET CODE= BarChart.class WIDTH=300 HEIGHT=250> <PARAM NAME ="columns" VALUE ="4"> <PARAM NAME ="c1" VALUE ="110" > <PARAM NAME ="c2" VALUE ="150"> <PARAM NAME ="c3" VALUE ="100"> <PARAM NAME ="c4" VALUE ="170"> <PARAM NAME ="label1" VALUE ="year91"> <PARAM NAME ="label2" VALUE ="year92"> <PARAM NAME ="label3" VALUE ="year93"> <PARAM NAME ="label4" VALUE ="year94"> <PARAM NAME=EndLabel1 VALUE="110"> <PARAM NAME=EndLabel2 VALUE="150"> <PARAM NAME=EndLabel3 VALUE="100"> <PARAM NAME=EndLabel4 VALUE="170"> </APPLET> </HTML>
•
•
Join Date: Jan 2008
Posts: 3,844
Reputation:
Solved Threads: 503
EndLabel[0] = getParameter("Label1");
EndLabel[1] = getParameter("Label2");
EndLabel[2] = getParameter("Label3");
EndLabel[3] = getParameter("Label4");<PARAM NAME="EndLabel1" VALUE="110"> <PARAM NAME="EndLabel2" VALUE="150"> <PARAM NAME="EndLabel3" VALUE="100"> <PARAM NAME="EndLabel4" VALUE="170">
You have getParameter looking for the parameter that goes with "Label1", etc. rather than "EndLabel1", etc.
![]() |
Similar Threads
- a simple one bar for using a percentage movement (Pascal and Delphi)
- confused about paintocomponent (Java)
- Help with investment calculator (Java)
- How can i prepare a histogram (Java)
Other Threads in the Java Forum
- Previous Thread: Stacks Help
- Next Thread: java Thread
Views: 524 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application arguments array arrays automation binary bluetooth c# capture chat chatprogramusingobjects class classes client code color component count database detection draw eclipse eclipsedevelopment encryption error event exception file fractal game givemetehcodez graphics gridlayout gui helpwithhomework high html ide if_statement image input integer j2me java javadesktopapplications javaprojects jmf jni jpanel julia keyword linux list loop macintosh map method methods mobile multithreading netbeans newbie number object oracle os print problem producer program programming project projectideas read recursion replaysolutions scanner screen server set size sms socket sort sql string swing test threads time transfer transforms tree ui unicode windows






