answersLogoWhite

0


Best Answer

import java.awt.*;

import java.applet.*;

public class barChart extends Applet {

String label[];

int values[];

int n = 0;

public void init() {

try {

n = Integer.parseInt(getParameter("cols"));

label = new String[n];

values = new int[n];

label[0] = getParameter("label1");

label[1] = getParameter("label2");

label[2] = getParameter("label3");

label[3] = getParameter("label4");

values[0] = Integer.parseInt(getParameter("values1"));

values[1] = Integer.parseInt(getParameter("values2"));

values[2] = Integer.parseInt(getParameter("values3"));

values[3] = Integer.parseInt(getParameter("values4"));

} catch (NumberFormatException e) {

}

}

public void paint(Graphics g) {

g.setColor(Color.red);

for (int i = 0; i < n; i++) {

g.drawString(label[i], 100, 100 + i * 50);

g.fillRect(150, 80 + i * 50, values[i], 40);

}

}

}

<html>

<body>

<applet code="barChart.class" height="700" width="700">

<param name="cols" value="4" />

<param name="label1" value="1994" />

<param name="label2" value="1995" />

<param name="label3" value="1996" />

<param name="label4" value="1997" />

<param name="values1" value="110" />

<param name="values2" value="100" />

<param name="values3" value="190" />

<param name="values4" value="140" />

</applet>

</body>

</html>

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you create bar chart using java applet?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is it possible to draw in java without using applet?

Yes it is possible to draw in java by using AWT package. or by using javax package.


When an applet become an applet?

Any Java class that extends java.applet.Applet is an applet. http://java.sun.com/j2se/1.5.0/docs/api/java/applet/Applet.html


Differences between Java Applet and Java Beans?

Java applet is a program used to run java applications while beans is a compiler used to design java programs (IDE, GUI) :-) GilbertC


Can you give the codes of the flag of Philippines using java applet?

System.out.println("No.");


Coding for creating HTML editor using java applet?

&lt;html&gt; &lt;body&gt; java applets&lt;/body&gt;&lt;/html&gt;


How do you you Create 2 text-field and 1 button in java using applet and then get the input as integers in 2 text-field and to display the output in label already created when you click the button?

How to you Create 2 text-field and 1 button in java using applet and then get the input as integers in 2 text-field and to display the output in label already created when you click the button? please send immediately,needed urgently


What is the DOS command applet?

There is nothing called DOS applet.. You can run Java applet from DOS..


How do you run applet program?

By Embedding it into a HTML page, create a new file with the extension .html (like app.html) insert following code: No Java 2 SDK, Standard Edition v 1.4.2 support for APPLET!! Adjust the code for your applet file (can't help there i am not a java programmer) or just use : No Java 2 SDK, Standard Edition v 1.4.2 support for APPLET!! but i recommend the first because the applet tag is deprecated and not supported in XHTML


What is an important difference between writing a Java application and a Java applet?

A Java applet is embedded within a web page, while a Java application will run directly on your computer.


What is applet in javahow it works?

Applets allow you to do frontend in java. You can draw things like rectangle,circle etc or create buttons and textboxes or you could even create a game! You can make use of the powerful api of java to design the applet and make use of awk(abstract window kit).


What is a Java applet?

PCH answer small Embedded Java Program.


Differentiate Java applet and Java servlet?

Java Applet is an application designed to transmit on internet to execute on java compatible browsers. Java Servlet is a server side program used to provide services to clients.