Why does my Java program not recognise a static variable in a particular class? -


i doing test code inventory system (i plan work on game later on) using javax components. making class called 'cursor' extends 'itemstack' can "pick up" items click on in inventory screen. problem i'm having use static variable 'cur' hold instance of class, every time try compile, following error:

.\john\window\component\itemslotpanel.java:13: error: cannot find symbol     itemstack.swapwith(cursor.cur);                              ^   symbol:   variable cur   location: class cursor .\john\window\component\itemslotpanel.java:25: error: package itemstack.item doe s not exist       g.drawimage(itemstack.item.icon.getscaledinstance(this.getwidth(),this.get height(),image.scale_smooth),0,0,null);                                 ^ .\john\window\component\infiniteitemslotpanel.java:15: error: cannot find symbol      if (cursor.cur.isempty()) {               ^   symbol:   variable cur   location: class cursor .\john\window\component\infiniteitemslotpanel.java:16: error: cannot find symbol        this.itemstack.copyto(cursor.cur);                                   ^   symbol:   variable cur   location: class cursor .\john\window\component\infiniteitemslotpanel.java:17: error: cannot find symbol      } else if (cursor.cur.item.id == this.itemstack.item.id) {                      ^   symbol:   variable cur   location: class cursor .\john\window\component\infiniteitemslotpanel.java:18: error: cannot find symbol        cursor.cur.count += this.itemstack.count;             ^   symbol:   variable cur   location: class cursor 6 errors 

which implies variable doesn't exist

i have attempted find similar problems on site (as through google), of have found irrelevant. on stackoverflow, found questions what reflection , why useful?, bytecode features not avaliable in java language, , benefits of prototypal inheritance on classical.

the class in question:

package john;  import java.awt.*; import java.awt.event.*; import javax.swing.*;  import john.item.*; import john.window.*; import john.window.component.*;  public class cursor extends itemstack implements mouselistener,mousemotionlistener {   public static cursor cur = new cursor();    public cursor() {     super(null);   }    public static cursor getcursor() {     return cur;   }    public void mouseclicked(mouseevent e) {     object source = e.getsource();     if (source instanceof infiniteitemslotpanel) {       ((infiniteitemslotpanel) source).mouseclicked(e);     } else if (source instanceof itemslotpanel) {       ((itemslotpanel) source).mouseclicked(e);     }   }   public void mouseentered(mouseevent e) {    }   public void mouseexited(mouseevent e) {    }   public void mousepressed(mouseevent e) {    }   public void mousereleased(mouseevent e) {    }   public void mousedragged(mouseevent e) {    }   public void mousemoved(mouseevent e) {    }    public cursor addlistenerto(component x) {     x.addmouselistener(this);     x.addmousemotionlistener(this);     return this;   } } 

itemstack.java:

package john.item;  public class itemstack {   public item item;   public int count;    public itemstack(item item) {     this(item,1);   }   public itemstack(item item,int count) {     this.item = item;     this.count = count;   }    public boolean isempty() {     return this.item == null && this.count == 0;   }   public void check() {     if (this.count < 0) {this.count = 0;this.item = null;}     if (this.item == null && this.count > 0) this.count = 0;     if (this.count == 0 && this.item != null) this.item = null;   }   public void dispose() {     this.item = null;     this.count = 0;   }   public boolean caninsert(itemstack stack) {     return this.item.id == stack.item.id;   }   public void insert(itemstack stack) {     if (!caninsert(stack)) return;     this.count += stack.count;   }   public void insertinto(itemstack dest) {     dest.insert(this);   }   public void copyto(itemstack dest) {     dest.item = this.item;     dest.count = this.count;   } } 

if need more code this, don't hesitate ask, i'll best condense it, consists of 14 interlocking classes, don't know how go.

i not sure how question received, don't know else go. apologise if wasting time, tried make question fit stackoverflow's guidelines. reply appreciated (even negative ones). need figure out why happening. last time had problem similar one, had delete , rewrite everything, information great! also, sorry poor english (i american born-and-raised, don't write kind of thing anymore).


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -