Results 1 to 4 of 4
  1. #1
    tkas is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Default Problem with Array and Joptionpane

    Hi all,
    I want to create an array of 100 integers and then I want in a pop up window a user to fill it with a number from 1 to 100.
    then another window will inform my user that his number is in the X index of the array.
    So far I have written this.


    package elearning;

    import javax.swing.JOptionPane;


    public class BigArray {

    /**
    * @param args
    */
    public static void main(String[] args) {

    String entervalue;
    int[] array = new int[100]; // create my array

    for (int i = 0; i < array.length; i++){
    array[i]= i+1;


    for (int element : array){
    entervalue = JOptionPane.showInputDialog (null, "give a number from" + array[0] + "to" + array.length);
    array[i] = Integer.parseInt( entervalue );

    if (array[i] == element)
    break;
    }
    JOptionPane.showMessageDialog(null, "The number " + array[i] + " is in" +array + " τof array", "Message", JOptionPane.INFORMATION_MESSAGE );
    System.exit (0);
    }
    }
    }


    Any help would be apreciated

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

    Default Re: Problem with Array and Joptionpane

    Quote Originally Posted by tkas View Post
    Hi all,
    I want to create an array of 100 integers and then I want in a pop up window a user to fill it with a number from 1 to 100.
    then another window will inform my user that his number is in the X index of the array.
    So far I have written this.

    .....

    Any help would be apreciated
    You'll want to ask an actual question. So far all I see are what you want, not specificially where you're stuck.

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

    Default Re: Problem with Array and Joptionpane

    Plus it is a duplicate post!

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

    Default Re: Problem with Array and Joptionpane

    Quote Originally Posted by Junky View Post
    Plus it is a duplicate post!
    @Junky: Thanks!

    To the original poster, please don't post the same question multiple times in the forum as it is not fair to us to unnecessarily divide a discussion.

    Also, how would you expect a different answer when you still don't ask a direct question??

    Locking.

Similar Threads

  1. Problem with JOptionPane
    By chrisLU5 in forum New To Java
    Replies: 8
    Last Post: 05-05-2011, 10:04 PM
  2. Replies: 13
    Last Post: 03-20-2010, 01:03 AM
  3. using javax.swing.JOptionPane in array
    By icedragon770 in forum AWT / Swing
    Replies: 12
    Last Post: 11-10-2008, 08:27 AM
  4. JOptionPane problem
    By MomenT in forum New To Java
    Replies: 22
    Last Post: 10-02-2008, 05:56 PM
  5. String array for Choice, JOptionPane doesn't show
    By themburu in forum Java Applets
    Replies: 5
    Last Post: 05-29-2008, 01:10 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
  •