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

Thread: Joptio pane not correctly outputting stored values. (Help please)

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Joptio pane not correctly outputting stored values. (Help please)

    Below is the code im having issues with it compiles fine and runs , but as i put in information in the joptionpane box with option 1)init and try to
    display it with option 2) listinformation it pops up the error that "no students entered".

    What I want it do is list all the students , gpas , and need with a JOptionPane.showMessageDialog

    Please please help.



    hid , solved
    Last edited by makominami; September 9th, 2013 at 12:21 AM. Reason: code tags


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Joptio pane not correctly outputting stored values. (Help please)

    Please post your code in code tags. You can learn how here, and then you can edit your post and add them.

    The init() method is set up to keep track of the number of students entered, but the returned value 'count' is not stored by the calling statement. It's discarded. Since it is discarded, the program has no indication that student info has been entered or how many. To store the count value returned by init(), change the calling statement to:
    if(choice.equals("1")){
        numStudent = init(firstname,lastname, gpa, need, numStudent );
    Now, as for your design, using parallel arrays to store data is the path to ruin. Instead, create a Student class and store all of the necessary characteristics in fields in the Student objects. If you can and would like to pursue this approach, let us know. Perhaps this is a stepping stone and your not allowed to make the step to a Student class yet. If so, I understand.

Similar Threads

  1. Tabbed Pane not showing up.
    By Tyluur in forum What's Wrong With My Code?
    Replies: 9
    Last Post: February 25th, 2013, 01:53 PM
  2. Help incorporating a Joption Pane
    By Dysun in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 15th, 2012, 05:25 PM
  3. What exactly is a content pane?
    By TP-Oreilly in forum Java Theory & Questions
    Replies: 2
    Last Post: December 7th, 2011, 09:07 AM
  4. Replies: 3
    Last Post: May 21st, 2011, 08:47 AM
  5. JOption Pane help
    By dallas1125 in forum AWT / Java Swing
    Replies: 5
    Last Post: November 18th, 2009, 05:08 PM