Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2003

Tip: Looking for answers? Try searching our database.

What wrong? (Compiler error message)

Thread view: 
Daniel Janzon - 28 Nov 2003 18:23 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 :/

   / 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.