Results 1 to 2 of 2
Thread: Non-static method error
- 09-21-2009, 04:37 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 21
- Rep Power
- 0
Non-static method error
Hello there.
When I compile the below piece of code, whether the method is static or not, I get "non-static method cannot be referenced from a static context".
Java Code:public static void createSprite(int spriteID, int x, int y) { BufferedImage img = null; try { img = ImageIO.read(new File("Sprites/" + spriteID + ".png")); Graphics.drawImage(img, x, y, null); } catch (IOException e) { } }
The error:
Java Code:Client.java:197: non-static method drawImage(java.awt.Image,int,int,java.awt.ima ge.ImageObserver) cannot be referenced from a static context Graphics.drawImage(img, x, y, null);
If someone could point out to me what's wrong, or give me a hint on why it does that, I'd be very grateful.
Thanks in advance.
- 09-21-2009, 04:56 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Similar Threads
-
Public static method error
By leapinlizard in forum New To JavaReplies: 5Last Post: 04-29-2009, 11:10 PM -
error: non-static method newAnimal() cannot be referenced
By alpdog14 in forum New To JavaReplies: 3Last Post: 04-11-2009, 09:14 PM -
static method sparks error on overriding non-static method
By MuslimCoder in forum New To JavaReplies: 1Last Post: 02-10-2009, 10:03 AM -
Non-Static method in static context error
By wizmang in forum New To JavaReplies: 4Last Post: 04-24-2008, 08:51 AM -
Error: Non-static method append(char) cannot be referenced from a static context
By paul in forum Advanced JavaReplies: 1Last Post: 08-07-2007, 05:05 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks