The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

applet vanishes in MSIE

Posted by Randy Larsen on September 18, 2000 at 8:08 PM

First off please excuse me if this is a very elementary question. I am new to this.

I've written an applet that takes parameters from a (Cold Fusion) web page and displays a pie chart. It seems to work fine in Netscape Communicator (4.61) but MSIE 5 flashes the piechart for only a tiny fraction of a second and then overwrites it with the background. Can anyone tell me what i'm doing wrong?

Thanks,
Randy Larsen

The source code follows:

/**************************************************************/
import java.awt.*;
import java.applet.*;


public class stdRptPie extends Applet{

float startAng = 0;
float sweptAng = 0;

float total = 0;
float mmSubTot = 0;

int i = 0;
int left = 70;
int bottom = 250;

int parsetot1 = 0;
int parsetot2 = 0;
int parsetype1 = 0;
int parsetype2 = 0;

String grandTot;
String totStr;
String typeStr ;

String totSub;
String typeSub;

private Font font;


public void init(){
setBackground(Color.black);
grandTot = getParameter("totResp");
totStr = getParameter("mmTot");
typeStr = getParameter("mmType");
total = (float)Integer.parseInt(grandTot);
font = new Font("Helvetica", Font.PLAIN, 12);
}


public void paint(Graphics g){

g.setFont(font);

while(true){
i++;
parsetot2 = totStr.indexOf(',', parsetot1);
totSub = totStr.substring(parsetot1,parsetot2);
parsetot1 = parsetot2 + 1;

if(parsetot2 == -1){
break;
}

parsetype2 = typeStr.indexOf(',', parsetype1);
typeSub = typeStr.substring(parsetype1,parsetype2);
parsetype1 = parsetype2 + 1;


switch(i){
case 1:
g.setColor(Color.red);
break;
case 2:
g.setColor(Color.green);
break;
case 3:
g.setColor(Color.blue);
break;
case 4:
g.setColor(Color.yellow);
break;
case 5:
g.setColor(Color.gray);
break;
case 6:
g.setColor(Color.orange);
break;
case 7:
g.setColor(Color.black);
break;
}

mmSubTot = (float)Integer.parseInt(totSub);

sweptAng = 360 * (mmSubTot/total);

g.fillArc(20, 20, 200, 200, (int)startAng, (int)sweptAng); //cast

g.drawString(typeSub + " = " + totSub, left, bottom);
bottom += 15;
//g.setColor(Color.black);
//g.drawString("start = " + startAng + ", swept = " + sweptAng + ", total = " + total, left, bottom);
//bottom += 15;
startAng += sweptAng;
}
}
}




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us