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 4 of 4

Thread: Hello Java Forums!

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    12
    My Mood
    Confused
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Wink Hello Java Forums!

    Hello gang,

    I am looking for some direction - I can program but I am an industrial Engineer and so I program Electronics such as PICs and also lots of PLC Software... I have no Java experience but I used to be quite good with Fortran!

    My son has come home from school and he wants to build a decision based text game and so I have committed to assist him build it in Java >.< So I need some pointers - I will be using Netbeans and have a rough understanding of the bare bones of a simple Java program (Hello World!!)

    So here is my first question:

    I would like to print one of several responses onto the screen based on an answer that I give to a question ie.

    Question: You have entered a room, there are 3 doors please choose a door to enter: a) Door to the left, b) Door straight ahead, c) Door to the right

    I then input a, b or c and then some text will be printed to the screen.

    Please help - Ian


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Hello Java Forums!

    I think a moderator will end up moving this out of the Member Introduction area, but I'll give my 2 cents nonetheless. There are several ways you could design something like this.

    You could just print out the question with its option in a JLabel, JTextArea, or something and have a JTextField under it for user input. You would then add a JButton for the user to press when they are ready to submit their answer (which you would attach with an action listener that reads the JTextField). Or you could attach a carrot listener to the JTextField that fires as soon as anything is typed in the JTextField (assuming the user input is only one character, there is nothing wrong with that).

    Another way I can think of doing it is print out the question without its options in a JLabel, JTextArea, or whatever and have a JList under it with each option. The user could then select the option from the JList, which would then fire a selection listener (or action listener, not sure if JLists support selection listeners) to process the selection the user made.

    You can read about all of this stuff by going through the GUI Oracle Tutorials and by doing a bit of trial-and-error.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. The Following User Says Thank You to aussiemcgr For This Useful Post:

    iansmiler (May 23rd, 2012)

  4. #3
    Junior Member
    Join Date
    May 2012
    Posts
    12
    My Mood
    Confused
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Re: Hello Java Forums!

    Thanks for that - I am going to have a good play right now over a couple of glasses of wine (I'll also post this in the appropriate forum!)

  5. #4
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Hello Java Forums!

    aussiemcgr addressed how a gui might look, but I'm not sure from your question if that's the problem or whether it's the logic (and associated Java constructs) that you are unsure of.

    If the latter is the case begin with a command line program ("HelloWorld" extended) which should teach you Java's take "control of flow" constructs and basic i/o.

Similar Threads

  1. Replies: 6
    Last Post: April 9th, 2012, 02:41 PM
  2. Java Programming Forums Custom Software
    By macko in forum The Cafe
    Replies: 6
    Last Post: November 4th, 2011, 07:45 AM
  3. Greeting to JAVA forums
    By ClassicD in forum Member Introductions
    Replies: 1
    Last Post: January 26th, 2011, 11:24 AM
  4. HAPPY 2nd BIRTHDAY JAVA PROGRAMMING FORUMS!!!
    By JavaPF in forum The Cafe
    Replies: 55
    Last Post: May 24th, 2010, 03:43 AM
  5. Hello java programming forums
    By DnB in forum Member Introductions
    Replies: 2
    Last Post: February 9th, 2009, 07:38 AM