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 reference
Page Index Toggle Pages: 1
Static reference (Read 937 times)
Static reference
May 4th, 2010, 1:47pm

I am calling a Bluetooth class's method drawAllBluetoothStuff with Bluetooth.drawAllBluetoothStuff() which causes me to get the error "Cannot make static reference to the non-static method drawAllBluetoothStuff"

So I made everything in the bluetooth class static, though when I tried to draw a rect, I got the error Cannot make static refrence to the non-static method rect(float, float, float, float).

I'd perfer to fix this by making the Bluetooth class non-static and calling it from setup().

Can someone help me out?
Re: Static reference
Reply #1 - May 4th, 2010, 2:51pm
How about creating an object of the bluetooth class, then you don't need to make anything static.. unless there's some reason that you need the Bluetooth class to have static methods.
Re: Static reference
Reply #2 - May 4th, 2010, 2:52pm
You need to create an instance of Bluetooth class and access the .drawAllBluetoothStuff() from the instance, e.g.:

class Bluetooth {
 void drawAllBluetoothStuff() {

void setup() {
 Bluetooth bt = new Bluetooth();

static methods are methods that can be called without an instance of the class; conversely, a non-static method can only be called with an instance.
Page Index Toggle Pages: 1