I have to objects. One secondary object with a method "public boolean
f(int x, int y)" and a main object creating this secondary object and
calling the method. It doesn't compile since "no-static method f...
cannot be referenced from a static context". This doesn't mean anything
to me :/
/ Any help is much appreciated, Dan

Signature
Be sure to include the word zebra in the subject line of any mail sent
to my email adress fergusprint@casino.com since it will be automatically
removed otherwise!
Brad BARCLAY - 28 Nov 2003 18:49 GMT
> I have to objects. One secondary object with a method "public boolean
> f(int x, int y)" and a main object creating this secondary object and
> calling the method. It doesn't compile since "no-static method f...
> cannot be referenced from a static context". This doesn't mean anything
> to me :/
If the error doesn't mean anything to you, then you have a whole lot
more to learn about Java.
Go and read up on the differences between static members (aka "class
members") and non-static members (aka "object members"). You should be
able to solve your problem then.
Brad BARCLAY

Signature
=-=-=-=-=-=-=-=-=
From the OS/2 WARP v4.5 Desktop of Brad BARCLAY.
The jSyncManager Project: http://www.jsyncmanager.org
Jose Rubio - 28 Nov 2003 18:50 GMT
The source code would help to diagnose the problem.
Jose
> I have to objects. One secondary object with a method "public boolean
> f(int x, int y)" and a main object creating this secondary object and
[quoted text clipped - 3 lines]
>
> / Any help is much appreciated, Dan
Dan - 29 Nov 2003 15:17 GMT
> The source code would help to diagnose the problem.
What I basically want to do is to paint on an image in my non-main
object, then pass this image to the main function (which is an applet),
thus being able to draw i using drawImage in the paint-function. The
erroneous source code is this (stripped from uninteresting parts)
import java.awt.*;
import java.awt.image.*;
public class Arnold {
private Image im;
private Graphics imGraphics;
public void Arnold() {
//im = new Image(); // Not possible
//imGraphics = new Graphics();
im = Component.createImage(1,1); //
imGraphics = im.getGraphics();
}
// Methods painting on im via imGraphics
public Image getImage() {
return im;
}
}
/ Dan
Roedy Green - 28 Nov 2003 19:11 GMT
>no-static method f...
>cannot be referenced from a static context
look the error up in http://mindprod.com/jgloss/errormessages.html
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Alex Hunsley - 29 Nov 2003 02:58 GMT
> I have to objects. One secondary object with a method "public boolean
> f(int x, int y)" and a main object creating this secondary object and
[quoted text clipped - 3 lines]
>
> / Any help is much appreciated, Dan
You're probably trying to access the method of a class from your main()
method, which is static (i.e. doesn't require an instantiation to be run).
Try making a new instance of the class containing the method, and then
call the method on that instance.