Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Imagedrawing

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Imagedrawing

    Ok so im making my own little 2d game and im trying to make my titlebackground load..

    But everyway i just fail...

    Ingore imports

    /**
    * Sprite class
    * @author - Joe
    * 28/10/2010
    */
    class Sprite {

    public void sprite (Sprite ref) {

    }

    /**
    * Joseph Dilkes
    */
    private static void createAndShowGUI() {
    JFrame frame = new JFrame("Project-Gore Client");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
    frame.pack();
    Image image = new ImageIcon("cache/sprites/title.png").getImage();
    frame.setSize(700,500);
    frame.setVisible(true);
    }
    as you can see i have

    Image image = new ImageIcon("cache/sprites/title.png").getImage();
    but it dosent work.

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Imagedrawing

    Quote Originally Posted by Ironik View Post
    but it dosent work.
    Please define doesn't work. Exceptions? Null values? No image being drawn? Is your image in the correct location?

  3. #3
    Junior Member
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Imagedrawing

    No image being drawn.
    and the answe to you're question the image is in the right location.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Imagedrawing

    The code you posted retrieves said image, but doesn't do anything with it. What do you want to do with the Image once you retrieve it?

  5. #5
    Junior Member
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Imagedrawing

    to display on the client..

  6. #6
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: Imagedrawing

    Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    db

  7. The Following User Says Thank You to Darryl.Burke For This Useful Post:

    javapenguin (November 4th, 2010)