Results 1 to 2 of 2
  1. #1
    elvis0288 is offline Member
    Join Date
    Jan 2012
    Posts
    21
    Rep Power
    0

    Default I want to use StdDraw or any other library to use .gif and show in animation

    hi my problem is that i want to use as targets baseball.gif that if you open that file is a baseball rotating... how can i import that baseball rotating that is a .gif picture into java using StdDraw or anything like that please help this is my code

    Java Code:
    package project1;
    
    import java.awt.Color;
    
    /**
     *
     * @author Elvis De Abreu
     */
    public class Target
    {
        /**declaring the x location of the target as a private*/
        private double x = 0;
        /**declaring the y location of the target as a private*/
        private double y = 0;
        /**declaring the radius of the target as a private*/
        private double radius = 0;
        /**declaring the alive color, the dead color and the background*/
        Color aliveColor, deadColor, background;
        
        /**
         * Constructor with no parameters
         */
        public Target()
        {
            
        }
        
        /**
         * constructor with 3 parameters
         * @param ax is the x location of the target
         * @param ay is the y location of the target
         * @param aradius is the radius of the target
         */
        public Target(double ax, double ay, double aradius)
        {
            x = ax;
            y = ay;
            radius = aradius;
        }
        
        /**
         * method that draw the picture when it is initialize
         * this method take no parameters
         */
        public void drawAlive()
        {
            StdDraw.setPenColor(StdDraw.LIGHT_GRAY);
            //SOMETHING LIKE THIS BUT IT IS NOT MOVING
            StdDraw.picture(getX(), getY(), "baseball.gif");
        }
        
        /**
         * method that draw the picture when it is shot
         * this method take no parameters
         */
        public void drawDead()
        {
            StdDraw.setPenColor(StdDraw.RED);
            StdDraw.filledCircle(getX(), getY(), getRadius());
        }
        /**
         * getter of the x location of the target
         * @return x
         */
        public double getX()
        {
            return x;
        }
    
        /**
         * getter of the y location of the target
         * @return y
         */
        public double getY()
        {
            return y;
        }
        /**
         * getter of the radius of the target
         * @return radius
         */
        public double getRadius()
        {
            return radius;
        }
        
        public String toString()
        {
            return("location of the target is: " + "(" + getX() + ","
                    + getY() + ")");
        }
    
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: I want to use StdDraw or any other library to use .gif and show in animation

    There isn't any StdDraw in the Java SE API.

    The easiest way to display an animated GIF is to set it as an ImageIcon to a JLabel.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. problems with StdDraw and Standard Drawing
    By elvis0288 in forum New To Java
    Replies: 0
    Last Post: 03-08-2012, 05:57 AM
  2. problem with StdDraw and Eclipse
    By elvis0288 in forum New To Java
    Replies: 1
    Last Post: 03-06-2012, 11:17 PM
  3. StdDraw.setXscale i have problems with this
    By elvis0288 in forum New To Java
    Replies: 3
    Last Post: 03-04-2012, 02:09 PM
  4. Animation doesn't show when used as action?
    By ryuzog in forum New To Java
    Replies: 1
    Last Post: 01-04-2010, 02:38 AM
  5. netbeans 6.0 not show commpunent or show blank page
    By fahimaamir in forum NetBeans
    Replies: 1
    Last Post: 01-26-2008, 07:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •