Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Problem in running the Applet in a browser

Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying to run an applet which should draw a graph with parameters it is passed with. When i run this with the help of applet viewer it works good. But when i try running it in a browser with the applet tag on it. It is giving a problem at setBounds method telling that java.awt.component nosuchmethod setBounds() at the bottom of the Browser at the status line.
Can any one help me in solving this problem.
Thanks a bunch
The program is
import java.awt.*;
import java.applet.Applet;
/* <APPLET CODE=Graph width=1000 height=1000>
<param name=Hidden1 value="100000">
<param name=Hidden2 value="430000">
<param name=Hidden2 value="430000">
<param name=Text1 value="Total Purchase Balance for jan 1998">
<param name=Text2 value="Total Purchase Balance for feb 1998">
<param name=Text12 value="Total Purchase Balance for dec 1998">
</applet> */
public class Graph extends Applet {
private String t[] = new String[100];
public double d[] = new double[100];
private int intD[] = new int[100];
public double bigElement,scaleFactor;
public int noOfElements;
private GraphCanvas drawArea;
public static final int CANVASXPOS = 20 ,CANVASYPOS = 20 , CANVASHEIGHT = 600, BARGRAPHWIDTH = 25;
public Color colorArray[] = {Color.yellow,,,Color.cyan};
private void processParms() {
for (int i=0;i>=0;i++) {
String temp = getParameter("Hidden"+(i+1));
if (temp != null) {
try {
d[i] = Long.parseLong(temp);
}catch(Exception e) {
d[i] = 0;
bigElement = (d[i] > bigElement) ? d[i]:bigElement;
t[i] = getParameter("Text"+(i+1));
else {
noOfElements = i;
System.out.println(" No of Elements = " + noOfElements);
i = -10;
public void init() {
drawArea = new GraphCanvas();
public void paint(Graphics g) {
Graphics g1 = drawArea.getGraphics();
/*for (int i=0;i<noOfElements;i++) {
System.out.println("color = " + (i%colorArray.length) + " i = " + i);
g1.fillRect(2*i*BARGRAPHWIDTH ,GRAPHHEIGHT - (int) (scaleFactor * d[i]),BARGRAPHWIDTH,(int)(scaleFactor * d[i]));
public void setScale() {
int i = 0;
while((bigElement = bigElement/Math.pow(10,i)) > Integer.MAX_VALUE) i++;
for (int x=0;x<noOfElements;x++) {
intD[x] =(int)(d[i] = d[i]/Math.pow(10,i));

scaleFactor = GRAPHHEIGHT / bigElement;

The code for GraphCanvas is
import java.awt.*;
public class GraphCanvas extends Canvas {
Graph GraphApplet;
public void storeApplet(Graph x) {
GraphApplet = x;
public void paint(Graphics g){
for (int i=0;i<GraphApplet.noOfElements;i++) {
System.out.println("color = " + (i%GraphApplet.colorArray.length) + " i = " + i);
g.fillRect(2*i*GraphApplet.BARGRAPHWIDTH ,GraphApplet.GRAPHHEIGHT - (int) (GraphApplet.scaleFactor * GraphApplet.d[i]),GraphApplet.BARGRAPHWIDTH,(int)(GraphApplet.scaleFactor * GraphApplet.d[i]));

Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like your browser is using an older version of Java which doesn't support "setBounds". setBounds was only introduced in Java 1.1, so if your browser doesn't fully support Java 1.1 you need to either:
1. Use the deprecated "reshape" method in your code. This takes the same parameters, but is deprecated, and may not be supported properly, if at all, in later Java versions.
2. Upgrade your browser to one which supports Java 1.1 properly
(Netscape 4.6 and above seem to work fairly well with Java 1.1 applets)
3. Install a Java plugin which supports a more recent version of Java.
If you are writing your code for Java 2 (ie Jave SDK 1.2 or 1.3), then option 3 is the only generally workable solution. In most cases Java 1.3 is much better than 1.2.
Chandar S Vellithirumutha
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks frank. from where can i download the plugins. I have Internet Explorer.
Frank Carver
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See my reply to an earlier thread at: .
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic