Results 1 to 11 of 11
Like Tree3Likes
  • 1 Post By Fubarable
  • 2 Post By tnrh1

Thread: Displaying a picture

  1. #1
    alexisw is offline Member
    Join Date
    Nov 2011
    Posts
    4
    Rep Power
    0

    Default Displaying a picture

    Hi! I'm a math/biology major who had to take a semester of Java programming. This means I had never seen it before and haven't used it since. I'm currently working on a "game" for kids to help them learn about marine animals. I started with looking around the internet so I could have a really cool game that allowed kids to click buttons and was interesting to look at, and quickly learned that that is way over my head. My next solution was then to write a simple game that would have a picture pop up after every question was either answered correctly or they ran out of guesses. That way they could see the animal I was referring to and it would give a little bit of information. The problem is, I only know how to do things that were taught in a basic java class for math majors. Can someone please tell me how to call up an image off of my computer? Thanks! This is one question done so you can see what I'm talking about:

    import java.util.Scanner;
    public class Project {
    public static void main(String[] args) {
    Scanner keyboard = new Scanner(System.in);
    System.out.println("Welcome! It's time to test your knowledge of fish!");
    System.out.println("Question 1: What type of camoflauge does the Angelfish use?");
    System.out.println("A. Cryptic Coloration");
    System.out.println("B. Silvery");
    System.out.println("C. Countershading");
    System.out.println("D. Eye Spots");

    String answer = keyboard.next();
    answer = answer.toUpperCase();

    int score = 0;

    for(int i = 2; i > 0; i--){
    if(answer.equals("D") ){
    System.out.println("Correct!");
    score = score + i +1;
    i=0;
    }
    else{
    System.out.println("Oops! Try again");
    answer = keyboard.next();
    answer = answer.toUpperCase();
    }


    }
    //right here I would want the image to pop up!

    System.out.println("Current Score = " + score);
    }
    }

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

    Default Re: Displaying a picture

    You will need to write a GUI for this. There are numerous ways to achieve it. I suggest you Google for a GUI tutorial.

  3. #3
    Dcalladi is offline Member
    Join Date
    Oct 2011
    Posts
    27
    Rep Power
    0

    Default Re: Displaying a picture

    i would suggest downloading netbeans as it had its own GUI builder and then find a tutorial.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Displaying a picture

    Quote Originally Posted by Dcalladi View Post
    i would suggest downloading netbeans as it had its own GUI builder and then find a tutorial.
    And I would suggest against this. If you don't know how to code in Swing, using NetBeans will not teach you how to do this and will only shield you from knowing necessary information on how to make anything more than the most basic of GUI's.
    DarrylBurke likes this.

  5. #5
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    4

    Default Re: Displaying a picture

    I asked the same question 1 month ago, and people reccomand me to learn the code itself and not using and gui builder/editor.
    I want to thank them, I understand the code and I can build gui interfaces easly.
    If you are new to the GUI in java, I would reccomand you to code it by your self, it's not that hard.
    DarrylBurke and Fubarable like this.

  6. #6
    alexisw is offline Member
    Join Date
    Nov 2011
    Posts
    4
    Rep Power
    0

    Default Re: Displaying a picture

    I tried at least 6 tutorials and I couldn't understand them. I don't even know if I was looking at the right tutorials. Is there one that someone suggests? And is there no simple way just to get a picture to pop up?

  7. #7
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    4

  8. #8
    alexisw is offline Member
    Join Date
    Nov 2011
    Posts
    4
    Rep Power
    0

    Default Re: Displaying a picture

    Already tried that one. I feel like people aren't understanding that I have close to no knowledge of the language. I was hoping someone could help me, not tell me to do something I already tried. I'm not being lazy by posting on here. This was just my last ditch effort to be able to do this. Tutorials really didn't help or make sense to me.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Displaying a picture

    Quote Originally Posted by alexisw View Post
    Already tried that one. I feel like people aren't understanding that I have close to no knowledge of the language. I was hoping someone could help me, not tell me to do something I already tried. I'm not being lazy by posting on here. This was just my last ditch effort to be able to do this. Tutorials really didn't help or make sense to me.
    It's not that we aren't trying to help you, it's just that we are unable to help you until you gain the knowledge base necessary to understand our suggestions. Like it or not, learning from tutorials is key, and like any skill it is hard to do at first but easier to do with practice and experience, trust me. The key is not to give up, to keep studying and restudying them. Another option is to engage a private tutor for intense one-on-one instruction. Best of luck!
    Last edited by Fubarable; 11-07-2011 at 10:32 PM.

  10. #10
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

    Default Re: Displaying a picture

    Quote Originally Posted by alexisw View Post
    I tried at least 6 tutorials and I couldn't understand them.
    Considering that anything that we posted here would be just repeating what was already said in all those tutorials what makes you think that you will understand our explanations any better? What you need to do is make an attempt. Write some code and when you get stuck post that code here, include error messages, explain fully what the problem is and ask a specific question. Only then can we help you.

  11. #11
    alexisw is offline Member
    Join Date
    Nov 2011
    Posts
    4
    Rep Power
    0

    Default Re: Displaying a picture

    Thanks everyone! I found a different thread that had someone who was able to tell me just enough to do what I wanted to do. I think the problem was that all the tutorials were overwhelming. I definitely can't do anything fancy, but I can get a picture to pop up :) Thanks again!

Similar Threads

  1. Getting a picture out of a jar?
    By Zman3359 in forum New To Java
    Replies: 4
    Last Post: 02-02-2011, 11:55 PM
  2. Get screenshot(picture) of own pc
    By shekhar2010 in forum New To Java
    Replies: 5
    Last Post: 01-24-2010, 03:48 AM
  3. picture backround
    By safiya in forum NetBeans
    Replies: 1
    Last Post: 10-18-2008, 07:13 AM
  4. Error With Simply Displaying Picture
    By JDCAce in forum Java Applets
    Replies: 4
    Last Post: 10-07-2008, 08:09 PM
  5. Picture help
    By deathnote11 in forum AWT / Swing
    Replies: 13
    Last Post: 06-03-2008, 05:46 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
  •