Results 1 to 2 of 2
  1. #1
    TheBigB is offline Member
    Join Date
    Jul 2010
    Posts
    1
    Rep Power
    0

    Default While loop for jpg

    How am I able to run a while loop with JOptionPane.showInputDialog to open pictures and then crash when nothing is entered. I just started using java, so any help would be useful. This is what I have now.

    static String show(String message, Object initValue) {
    String reply = null;
    if(initValue==null) reply=JOptionPane.showInputDialog(message);
    else reply=JOptionPane.showInputDialog(message, initValue);
    return reply;
    }

    public static void main(String[] args) {
    String s;
    s = show("Enter file name", null);
    System.out.println(s);
    while(s != ""){
    System.out.println(s);
    s = show("Enter file name", null);
    }
    }
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,883
    Rep Power
    25

    Default

    then crash when nothing is entered
    Please copy and paste full text of the error message here.

Similar Threads

  1. Replies: 5
    Last Post: 04-30-2010, 06:05 PM
  2. For Loop
    By YiBoog in forum New To Java
    Replies: 6
    Last Post: 11-11-2009, 08:53 PM
  3. Loop Help!
    By Keno777 in forum New To Java
    Replies: 3
    Last Post: 11-04-2009, 02:11 AM
  4. while-loop stopping on first loop
    By davester in forum New To Java
    Replies: 6
    Last Post: 06-26-2009, 09:46 PM
  5. While loop
    By verbazon in forum New To Java
    Replies: 5
    Last Post: 02-25-2009, 02:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •