Java Animation Compile Problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Java Animation Compile Problem

  1. #1
    Join Date
    Nov 2003
    Posts
    2

    Java Animation Compile Problem

    I am working on my first Java Animation using java.awt.* and javax.swing.* for my final intro to Java class project. My object (an elf) is created in a separate class and then I use the timer to move it across the screen. In the code for my elf, I have added a set value defined in a variable named MOVE to all x values. This compiles just fine for all shapes except my drawPolygon shapes. My polygons are defined correctly as I worked on the program as an applet until I completed it to look as I wanted and am now in the process of adding the animation. I cannot find anywhere where there is an example of a draw polygon or draw polyline that has the correct syntax. Can someone please tell me what I am doing incorrectly?? Thank you.
    Rita

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    ArchAngel.
    O:-)

  3. #3
    Join Date
    Nov 2003
    Posts
    2
    Thank you for the link to the Sun Java site but I am still having trouble adding the increment to my polygons. I get a compile error stating that " operator + cannot be applied to int[],int" One of my polygons is coded as follows:

    int [] xBag = {220, 200, 240, 220};
    int [] yBag = {150, 120, 120, 150};

    Then when I draw it I use the following:
    page.fillPolygon (xBag, yBag, xBag.length);

    For all of my other shapes, I have simply added a value defined in a variable "move" to the x value to create the illusion of movement. The compiler will not allow me to use the plus sign in the draw polygon??? Do I have to create a loop to add the appropriate value and draw the polygon??? I apologize if these questions are something that should be obvious, but I am totally baffled right now and do not have any idea of what to do to correct my error. Thank you.
    Rita

  4. #4
    Join Date
    Mar 2003
    Posts
    834
    Please post the exact error message and the lines to which it is referring.

    It sounds to me like you're trying to add a variable that is of type int[], rather than referencing a particular element e.g.
    Code:
    int[] myValue...
    
    myValue + ... // WRONG!
    myValue[1] + .... // RIGHT!
    ArchAngel.
    O:-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center