#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    43
    Rep Power
    3

    Drawing an image from URL?


    Im new to drawing graphicsIs this method working or should I add a paint method? Also, it gives an error : change ghost to ImageIcon, but then it changes the drawImage to drawLine.

    Code:
    URL url = new URL("http://1.bp.blogspot.com/_y3qWcWEV3Gc/TL-Ubk3mx0I/AAAAAAAAAJ0/UxcN2eXwCa4/s200/nes_ms_pac_man_ghost-copy.jpeg");
        	Image ghost = new ImageIcon(url);
        
        
            graphics.drawImage(ghost, x, y,  (ImageObserver) this);
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,575
    Rep Power
    1906
    what if change ghost to ImageIcon and then call the getImage() function
    Example (untested):
    Code:
        	URL url = new URL("....");
        	ImageIcon ghost = new ImageIcon(url);
    
            graphics.drawImage(ghost.getImage(), x, y,  (ImageObserver) this);

IMN logo majestic logo threadwatch logo seochat tools logo