1 Reply Latest reply: Oct 22, 2010 6:21 AM by DarrylBurke RSS

    Access a variable from a canvas

      Hi guys.
      I defined a variable like this:

      in midlet:

      public int XX,YY;

      I need to use this in my canvas:

      Mymidlet LF= new Mymidlet();
      int X,Y;

      This Code is not work!

      What is the problem?
        • 1. Re: Access a variable from a canvas
          1. As far as possible, avoid declaring variables public. Provide accessors and/or mutators only when needed.
          2. By convention, variable names in Java start with a lowercase letter.
          3. Pass a reference to the MIDlet to the constructor of the Canvas subclass using the <tt>this</tt> keyword.
          in midlet:
          No, in the <tt>MIDlet</tt>. This is a programming forum. Java is case sensitive. And if you really find it too much effort to use the correct case when posting on a forum, I doubt that you have what it takes to complete a program.

          If you still can't understand what you need to do, post a [url http://mindprod.com/jgloss/sscce.html]SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates where you're stuck.


          Edited by: Darryl Burke on 22 Oct, 2010 4:51 PM