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 › tabs and class
Page Index Toggle Pages: 1
tabs and class (Read 723 times)
tabs and class
Oct 19th, 2007, 4:48pm
 
Hi,

I've write a simple class using primitive to draw some shapes. Actually i've three tabs.

- One for the main program.
- One for my object class (that actually got three methods display(), increase() and decrease()).
- And another one dealing with all input/output events.

If i call the method increase and decrease into the third tab (on keyPressed() event)) i've got a message that the method is not static and cannot be accessed in this static context.

I know i'm doing something wrong, as i don't get the tab concepts and oee programming too...so i apologize.

Btw, I can post some code if needed (how to attach a file from the board) ?

Cheers, thx.
a.
Re: tabs and class
Reply #1 - Oct 19th, 2007, 5:08pm
 
you can't attach files to posts here .. sorry.

can you put it online somewhere else? we'd need to see what you are doing to see what's going on ..

the tabs are just there to make working in the PDE nicer. all except ".java" tabs are concatenated to one large text before being fed to the preprocessor. so there should be no difference in putting something in 1st, 2nd or 3rd tab (as long as they are not java-tabs).

F
Re: tabs and class
Reply #2 - Oct 19th, 2007, 5:20pm
 
Thx for the answer fjen. Actually it's processing only.
Very simple stuff. The code is there :

http://download.yousendit.com/75E5AAC939EA6C94.

Cheers.
Re: tabs and class
Reply #3 - Oct 19th, 2007, 6:01pm
 
the bad-class-naming-habit came back at ya there ..

"cc" is the name of the class ... "c" the name of the variable holding one instance of a "cc"-object. now look at the code inside keyPressed()!

static context means that you are calling functions from a class without creating an instance of it first. it's there because it allows for certain functions related to certain objects to stay inside that realm. String-related functions with String for example ...

F
Re: tabs and class
Reply #4 - Oct 19th, 2007, 6:04pm
 
Oh damn me, i forgot to change it in the io tab...But your explanation about static context clarify things for me.
Thx fjen.
Re: tabs and class
Reply #5 - Oct 19th, 2007, 7:16pm
 
Ok i added some interaction but i got sometimes the following error :

"java.lang.NullPointerException
at sun.java2d.pipe.AlphaColorPipe.renderPathTile(Unknown Source)
"

What does that mean ?

the code is here : http://download.yousendit.com/F3B1FC463F259F38

For exemple start the sketch and press ctrl+ "+" it'll display the error. Must be bad programming ???
Re: tabs and class
Reply #6 - Oct 19th, 2007, 7:35pm
 
i got a different error for display() saying that strokeWeight got passed a negative error ..

strokeWeight(innerRadius);

try:

strokeWeight(abs(innerRadius));

or:

strokeWeight( innerRadius < 0 ? -innerRadius : innerRadius );

F
Re: tabs and class
Reply #7 - Oct 19th, 2007, 7:36pm
 
btw. the keychecking is not working for me .. have an english system, with english key-names ..

F
Re: tabs and class
Reply #8 - Oct 20th, 2007, 12:35pm
 
Ok I've posted another version there :

http://download.yousendit.com/CB966F0D1CA83A58

Now you can hit + to make the object increase in size, - to make it decrease, 1 should increase the inner radius (at max giving a plain circle) 2 should decrease the inner radius size (at max giving only 1 pixel line circle).

I've still have the same error and sometimes the program just freeze, so must be something wrong with my code.
Page Index Toggle Pages: 1