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 & HelpSyntax Questions › Problems implementing size(int w, int h)
Page Index Toggle Pages: 1
Problems implementing size(int w, int h) (Read 729 times)
Problems implementing size(int w, int h)
Jul 9th, 2007, 11:04pm
 
I'm having problems using registerSize(Object o)  Running the code below from the PDE results in the following error message being written to the console:

java.lang.IllegalArgumentException: wrong number of arguments
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

I'm running Processing version 0124 from Linux, and am using the version of Java that ships with Processing. In the meantime I will build the latest Processing source code and see if the problem persists.

Here is the code that is causing the problem:

void setup() {

 Widget w = new Widget(this, 20, 20, 100, 100);
 registerSize(w);
 registerDraw(w);
 size(400, 400);
}

void draw() {
 // Do nothing.
}

public class Widget {
 public Widget(PApplet p, int x, int y, int w, int h) {
   this.p = p;
   this.x = x;
   this.y = y;
   this.width = w;
   this.height = h;
 }

 public void size(int w, int h) {
   this.width = w;
   this.height = h;
 }



 public void draw() {
   this.p.rect(this.x, this.y, this.width, this.height);
 }

 private PApplet p;
 private int x;
 private int y;
 private int width;
 private int height;
}
Re: Problems implementing size(int w, int h)
Reply #1 - Jul 10th, 2007, 6:43pm
 
Building the latest version of Processing (currently 3391) fixed this problem. Guess I didn't look hard enough in the bug database.
Re: Problems implementing size(int w, int h)
Reply #2 - Jul 10th, 2007, 10:04pm
 
as it says in the reference, do not put any code before size(). size() must be the first thing in setup, otherwise you'll have problems. changes in the most recent source may have contributed to it working, but do not put anything before size().
Re: Problems implementing size(int w, int h)
Reply #3 - Jul 10th, 2007, 10:17pm
 
I tried invoking size() first, and then invoking registerSize() but it still results in the same error.
Page Index Toggle Pages: 1