Results 1 to 3 of 3
  1. #1
    aconti is offline Member
    Join Date
    May 2011
    Posts
    39
    Rep Power
    0

    Default Run message only once

    Hi,

    how can I run the below once since it is repeating itself due to a while loop until criteria is met

    JOptionPane.showMessageDialog(null, "Guess a number between 1 and 500: ");

    I want to make the above appear only for the first time it runs

    Thanks !

  2. #2
    aconti is offline Member
    Join Date
    May 2011
    Posts
    39
    Rep Power
    0

    Default

    Ok found out,

    was very easy, just placed outside of the while loop :)

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,602
    Rep Power
    23

    Default

    Put the call inside of an if() {}
    Use value to only let it execute once.
    For example:
    Java Code:
    boolean oneTime = true;
      ...
    if(oneTime) {
      oneTime = false;  // turn off entry flag
      ...this will execute one time
    }

Similar Threads

  1. Replies: 6
    Last Post: 06-04-2010, 08:43 PM
  2. Matrix Message
    By shindry in forum New To Java
    Replies: 2
    Last Post: 05-04-2009, 04:32 AM
  3. Coded Message... Help Please
    By maxpower1000sa in forum New To Java
    Replies: 2
    Last Post: 05-03-2009, 08:27 PM
  4. Message NoClassDefFoundError
    By karim in forum Eclipse
    Replies: 1
    Last Post: 03-20-2009, 03:43 PM
  5. error message on jsp
    By sandor in forum Web Frameworks
    Replies: 1
    Last Post: 04-11-2007, 02:10 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
  •