Results 1 to 3 of 3
  1. #1
    j programer is offline Member
    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    Default how do i import images into a java program please

    i have been trying to teach myself how to do java but i have been having difficulty with how to import an image into class on a game

    please help

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,226
    Rep Power
    6

  3. #3
    vinci123 is offline Member
    Join Date
    Aug 2011
    Location
    INDIA
    Posts
    64
    Rep Power
    0

    Default Re: how do i import images into a java program please

    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import javax.imageio.ImageIO;

    public class ReadingImage {
    public void getImage() {
    try {
    BufferedImage image =
    ImageIO.read(getClass().getResource("Sunset.jpg")) ;

    // Do something with the image.
    } catch (IOException e) {
    e.printStackTrace();
    }
    }

    public static void main(String[] args) {
    ReadingImage ri = new ReadingImage();
    ri.getImage();
    }
    }

Similar Threads

  1. Replies: 0
    Last Post: 11-05-2010, 09:35 AM
  2. Ready To Program, Images in HSA Console?
    By habbah in forum New To Java
    Replies: 2
    Last Post: 01-17-2010, 03:50 AM
  3. need help in uploading images in swing program!!!
    By ashton in forum New To Java
    Replies: 10
    Last Post: 01-26-2009, 10:01 AM
  4. Replies: 4
    Last Post: 12-29-2008, 02:20 PM
  5. Already import the resources but images are missing
    By Java.child in forum New To Java
    Replies: 5
    Last Post: 09-05-2008, 05:09 PM

Posting Permissions

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