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.

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>
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.

i changed the code and it works now

EndLabel[0] = String.valueOf(value[0]);
EndLabel[1] = String.valueOf(value[1]);
EndLabel[2] = String.valueOf(value[2]);
EndLabel[3] = String.valueOf(value[3]);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.