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 › static method being hidden by member method
Page Index Toggle Pages: 1
static method being hidden by member method (Read 374 times)
static method being hidden by member method
Jan 22nd, 2008, 2:38pm
 
I'm a Java programmer who is playing with Processing.

I've come across a little problem: I'm writing a utility class (or should I say 'tab') in "extended" mode, in which I want to have a static method that has the same name as a normal method (but with different amount of parameters).
This wouldn't be a problem in normal Java, but Processing reports that the static method is 'hidden' by the the instance method, when I try to call the static method from within the class ('tab'?) itself.

What is the best approach to get around this? Renaming the static method to something else isn't really satisfactory for what I'm doing. I've had a brief look at Java mode, but haven't yet found a really good reference for how this works...
(e.g. do I just make the main class extend PApplet? Or should all tabs extend PApplet? etc.)

thanks!
lex

Re: static method being hidden by member method
Reply #1 - Jan 23rd, 2008, 5:57am
 
I expect it's an issue with inner classes. When you make a new tab and put a class in it, that tab winds up being packed into a single file with all the other tabs so any classes you define wind up as inner classes of your sketch class, which is the one that actually extends PApplet. If you want the classes you define to act like normal java classes you can change the file extension to .java and the precompiler won't stuff it into the sketch class.
Re: static method being hidden by member method
Reply #2 - Jan 23rd, 2008, 10:53am
 
Ahh thanks ddf, that's most helpful!
Page Index Toggle Pages: 1