FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   java.util.Vector inside p5 applet?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: java.util.Vector inside p5 applet?  (Read 2739 times)
arielm

WWW
java.util.Vector inside p5 applet?
« on: Apr 3rd, 2003, 11:30pm »

i'm playing a bit with java.util.Vector...
 
it works well under the p5 environment, and inside applets that runs with java2...
 
but on IE with the old microsoft VM, it produces an exeption (by the way, for the same reason, it seems that the "Pond" software by W. Ngan is not working)
 
according to sun's doc, Vector is there since JDK 1.0, so i expected it to work under the microsoft jvm...
 
any idea?
 
p.s: actually, my goal is to manage an array of integers that can grow dynamically... so if someone has a "cheap" alternative to vectors, i would be glad to hear...
 

Ariel Malka | www.chronotext.org
fry


WWW
Re: java.util.Vector inside p5 applet?
« Reply #1 on: Apr 3rd, 2003, 11:41pm »

you're probably using the toArray() method that's not in the 1.1 version (or one of the other methods that's not in the 1.1 version)
 
as you suggest, Vector is a bit overkill for integers. i like this sort of thing, and it's much speedier:
 
Code:
int list[];
int listCount;
 
void add(int what) {
  if (listCount == list.length) {  // grow ?
    int temp[] = new int[listCount<<1];
    System.arraycopy(list, 0, temp, 0, listCount);
    list = temp;
  }
  list[listCount++] = what;
}
 
arielm

WWW
Re: java.util.Vector inside p5 applet?
« Reply #2 on: Apr 4th, 2003, 12:06am »

thanks for the growable array example!
 
concerning Vectors...
 
well, it seems that the guilty method i used was "add", which is there since v1.2...
 
i should have use "addElement" instead (less elegant, even reminds macromedia director a bit, but seems to work!)
 

Ariel Malka | www.chronotext.org
fry


WWW
Re: java.util.Vector inside p5 applet?
« Reply #3 on: Apr 13th, 2003, 1:24am »

yeah, that's the gist of it. addElement will still work. anything post 1.1 won't work for exported applets, until we add an option to the exporting code for "target 1.1" or "target 1.3". we're hoping to avoid that situation, because it's ugly, but we'll probably have to do it someday.
 
Pages: 1 

« Previous topic | Next topic »