title: Why does my Java program not recognise a static variable in a particular class?
body: <p>I am doing some test code for an inventory system (I plan to work on a game later on) using Javax
  components. I was making a class called 'Cursor' which extends 'ItemStack' so that you can "pick up"
  items you click on in an inventory screen. The problem I'm having is that I use a static variable
  'cur' as to hold the instance of this class, but every time I try to compile, I get the following
  error:</p>
  
  <pre><code>.\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
  </code></pre>
  
  <p>which implies that the variable doesn't exist</p>
  
  <p>I have attempted to find similar problems on this site (as well as through Google), but most of what I
  have found is irrelevant. On StackOverflow, I found questions like <a href="https://stackoverflow.com/questions/37628/what-is-reflection-and-why-is-it-useful/37632?s=1|0.6684#37632">What is reflection and why is it useful?</a>, <a href="https://stackoverflow.com/questions/6827363/bytecode-features-not-available-in-the-java-language/23218472?s=2|0.2100#23218472">Bytecode features not avaliable in the Java language</a>, and <a href="https://stackoverflow.com/questions/2800964/benefits-of-prototypal-inheritance-over-classical/16872315?s=3|0.1578#16872315">Benefits of prototypal inheritance over classical</a>. </p>
  
  <h2>The class in question:</h2>
  
  <pre><code>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;
    }
  }
  </code></pre>
  
  <h2>ItemStack.java:</h2>
  
  <pre><code>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 &amp;&amp; this.count == 0;
    }
    public void check() {
      if (this.count &lt; 0) {this.count = 0;this.item = null;}
      if (this.item == null &amp;&amp; this.count &gt; 0) this.count = 0;
      if (this.count == 0 &amp;&amp; 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;
    }
  }
  </code></pre>
  
  <p>If you need more code than this, don't hesitate to ask, I'll do my best to condense it, but it currently consists of 14 interlocking classes, so I don't know how well that will go.</p>
  
  <p>I am not sure how well this question will be received, but I don't know where else to go. I apologise
  if I am wasting time, but I tried to make the question fit StackOverflow's guidelines. Any reply is appreciated (even negative ones). I just really need to figure out why this is happening. The last time
  I had a problem similar to this one, I had to delete and rewrite everything, so any information would be great! Also, sorry for my poor english (I am american born-and-raised, but I don't write this kind of thing very often anymore).</p>