Click to See Complete Forum and Search --> : Illegal start of expression at line 49:3


kk9110
10-21-2006, 07:36 PM
Hi ,

I am getting the following error when i run the program

import java.awt.*;
import java.lang.*;
import java.applet.*;

public class Chart extends Applet implements ActionListener
{

Button bar, pie;

public void init()
{


}


//repaint();
public void paint(Graphics g)
{

int val1 = Integer.parseInt(getParameter("edu"));
int val2 = Integer.parseInt(getParameter("util"));
int val3 = Integer.parseInt(getParameter("ent"));
int val4 = Integer.parseInt(getParameter("ref"));
int total;

float per1, per2, per3, per4;

int x=125, y=80, w=250, h=250;

int startAngle = 0, degrees;

total = val1 + val2 + val3 + val4;

per1 = val1 * 100.0f/total;
per2 = val2 * 100.0f/total;
per3 = val3 * 100.0f/total;
per4 = val4 * 100.0f/total;

pie = new Button("Pie Chart");
bar = new Button("Bar Chart");

add(pie);
add(bar);

pie.addActionListener(this);
bar.addActionListener(this);

public void actionPerformed(ActionEvent e)
{
String str = e.getActionCommand();
if(str.equals("Pie Chart"))
{
degrees = (int) (per1*360/100);
g.setColor(Color.red);
g.fillArc(x, y, w, h, startAngle, degrees);

startAngle = degrees;
degrees = (int) (per2*360/100);
g.setColor(Color.yellow);
g.fillArc(x, y, w, h, startAngle, degrees);

startAngle = startAngle + degrees;
degrees = (int) (per3*360/100);
g.setColor(Color.green);
g.fillArc(x, y, w, h, startAngle, degrees);

startAngle = startAngle + degrees;
degrees = (int) (per4*360/100);
g.setColor(Color.blue);
g.fillArc(x, y, w, h, startAngle, degrees);

g.setFont(new Font ("Sans-serif", Font.BOLD, 24));
g.setColor(new Color(0,0,0));
g.drawString("Pie Chart", 40,25);
}
else if(str.equals("Bar Chart"))
{
System.out.println("Yet");
}

repaint();
}

g.drawRect(40,350, 400, 145);

g.setFont(new Font("Verdana",Font.ITALIC, 24));
g.setColor(Color.black);
g.drawString("KEY", 45, 375);

g.setColor(Color.red);
g.fillRect(45, 385, 10, 10);
g.setColor(Color.yellow);
g.fillRect(45, 415, 10, 10);
g.setColor(Color.green);
g.fillRect(45, 445, 10, 10);
g.setColor(Color.blue);
g.fillRect(45, 475, 10, 10);

g.setFont(new Font("Verdana",Font.ITALIC, 20));
g.setColor(Color.black);
g.drawString(getParameter("key1") + "(" + Math.round(per1) + "%" + ")" , 60, 400);
g.drawString(getParameter("key2") + "(" + Math.round(per2) + "%" + ")" , 60, 430);
g.drawString(getParameter("key3") + "(" + Math.round(per3) + "%" + ")" , 60, 460);
g.drawString(getParameter("key4") + "(" + Math.round(per4) + "%" + ")" , 60, 490);
}
}

Can u tell me the error please

Regards,

Kailash

chazzy
10-22-2006, 10:24 PM
no,can you tell us what error you get back?