We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Applet ...notinited
Page Index Toggle Pages: 1
Applet ...notinited (Read 498 times)
Applet ...notinited
Mar 9th, 2009, 2:52pm
 
Hi,
i got the following example of the internet.  It works offline but when uploaded i get an error in the status bar saying that it is 'notinited'?

Any ideas?

thanks...

import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;
import java.io.*;
import java.util.*;

int num,curr;
PFont fnt;

String html[];

void setup() {
 size(600,600);

 fnt=createFont("Arial",12);
 frameRate(1);
 
 html=httpRequest("http://www.s-i-a-a.org/a/");
 if(html==null) exit();
}

void draw() {
 int linecnt=0,lineH=18;
 
 background(200,220,255);
 
 fill(0);
 noStroke();
 
 textFont(fnt,12);
 if(html!=null) {
   linecnt=0;
   for(int i=0; i<html.length; i++) {
     String tmp=stripHTML(html[i]);
     if(tmp.length()>0)
       text(tmp, 20,(linecnt++)*lineH+20);
   }
 }
}

String stripHTML(String html) {
 return html.replaceAll("\\<.*?\\>","");
}

String [] httpRequest(String url) {
 HttpClient client= new HttpClient();
 GetMethod meth=new GetMethod(url);
 
 try {
   int statusCode = client.executeMethod(meth);
   if(statusCode != HttpStatus.SC_OK) {
     println("HTTP Request failed.");
     return null;
   }
   
   int cnt=0;
   String [] str=new String[100];
   
   LineNumberReader in=new LineNumberReader(
     new InputStreamReader(meth.getResponseBodyAsStream()));

   String tmp;
   do {
     tmp=in.readLine();
     if(tmp!=null) {
       if(cnt==str.length) {
         String [] tmpstr=new String[cnt*2];
         for(int i=0; i<cnt; i++) tmpstr[i]=str[i];
         str=tmpstr;
       }
       str[cnt++]=tmp;
     }
   } while(tmp!=null);

   String [] tmpstr=new String[cnt];
   for(int i=0; i<cnt; i++) tmpstr[i]=str[i];
   str=tmpstr;
   
   println("HTTP request successful. "+cnt+" lines retrieved.");
   
   return str;
 }
 catch(Exception e) {
   println("Error: "+e.toString());
   return null;
 }
}
Re:  Applet ...notinited
Reply #1 - Mar 9th, 2009, 3:46pm
 
See How to sign an applet, I guess.
Page Index Toggle Pages: 1