Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8017287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:48:11+00:00 2026-06-04T20:48:11+00:00

After the user inputs their choices, the program seems to offer the same choices

  • 0

After the user inputs their choices, the program seems to offer the same choices again, followed by it completely freezing. It’s only set on there to give them the option once (I believe) and then follow the selections below. Instead it seems to revert back to the top, and then just freeze for some odd reason. Tried figuring it out for a while, but no avail.

public void init() //Initialize method {

    setSize(1000, 800); //Set size
    Container c = getContentPane();
    c.setBackground(Color.GREEN); //Set background
}    


public void paint(Graphics g)  {

    super.paint(g); //Start paint method
    g.setFont(new Font("Veranda", Font.PLAIN, 20));
    g.setColor(Color.BLACK);
    g.drawString("Hello", 250, 25); //top display message
    String number = JOptionPane.showInputDialog("Would you like a custom loop count or an infinite? 1. Custom 2. Infinite"); //test choice
    n = Integer.parseInt(number);

    while (n>0 || n<2)
    if (n==1) { 
            String number2 = JOptionPane.showInputDialog("How many times would you like to loop?");
            integer = Integer.parseInt(number2);
            while (integer>0)
                while (x < integer) {   
                    g.drawString("hi", 200, y); 
                    x+=1;
                    y = y+40; //test
                }//end while
    }//end if 
    else if (n==2)  {
        while (true); //im aware this is an endless loop. Can't find anything more stable for an endless one, so its just there for now..
    }//end if   
    else;
    g.drawString("Please pick a valid choice", 200, 200);               
}//end paint
}//end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:48:13+00:00Added an answer on June 4, 2026 at 8:48 pm

    This is what I understood

    while (integer>0) {
        while (x < integer)
        {   
            g.drawString("hi", 200, y); 
            x+=1;
            y = y+40; //test
        }//end while
        integer --; // <-- This is missing
    }
    break; // <-- Also missing
    

    The inner while ends when x = integer
    but integer is always > 0
    you have to do integer -- at the end of the outer loop
    So it can go to 0 at some point

    Please use proper indentation… it helps

    I edited the code… see where I put the ‘integer –‘

    try converting your while(n>0 || n<2) to if(n>0 && n<2)

    Try not using while instead of if, it creates less confusion

    Add brackets {} for all your code blocks, easier to read, hence easier to debug, maybe you’ll figure it out by just doing that

    Also is the ; after the last else intended?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my recaptcha to appear only after user clicks submit button on the
How can I edit this to run only once after user scroll up: (function
I am trying to change text input value after user fill it, to uppercase
This works in clearing in input after a user submits it via ajax on
Goal : After user saves data to my mysql DB, a JSON teaser of
I want to INSERT VALUES after user has clicked OK on the confirmation box.
I am customizing the confirmation email sent after user registration. My problem is that
I need an event/events that will do the following: After user selects text/DOM element,
I have pay now form on my page and after user finishes his payment
Is it possible to get shutdown reason in Windows Server 2008 immediately after user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.