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 7797725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:46:37+00:00 2026-06-01T23:46:37+00:00

How do I make it so that the program doesn’t keep reading in code

  • 0

How do I make it so that the program doesn’t keep reading in code until the button is clicked?

Why?: I have a 10×10 grid with buttons in each part and then code running depending on what is clicked. However, my program keeps reading in code so there is never a choice being made and it gives me error. I tried giving it a infinite loop until a button is pressed, but that doesn’t work out so well

-edit
I’m a complete beginner with Java.

This is a picture of the GUI

GUI

http://imageshack.us/content_round.php?page=done&l=img843/5351/sascp.png

What I want is for the code to not keep running step by step until I click a button.

E.G.:

  • create gameGUI
  • wait until and check which button is pressed

if(buttonClicked[i][k] == something){
  System.out.println("lool");
}

But what’s happening in my code is that it creates the gameGUI and then because the user isn’t fast enough to click it just skips over the if statement or gets a run-time error because nothing was pressed.

  • 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-01T23:46:40+00:00Added an answer on June 1, 2026 at 11:46 pm

    In both Android & Swing (& I’d expect J2ME), buttons fire events when told to do so (by activating them). You would generally just wait for that to happen before doing anything, and not bother with what the rest of the GUI is doing (or not doing) at the time.

    Or in other words:

    • Add an ActionListener to the buttons.
    • In the actionPerformed() method, insert the code that you have above.

    Also

    • The code snippet provides almost no useful information. For better help sooner, post an SSCCE.
    • That GUI looks like Swing to me. If it is not, then what is it?
    • Please always copy/paste run-time errors.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the code [usrs addObject:usrString] I am trying to make it so that
This is the program that i make. But i doesn't run good. when i
Say I make a program that keeps track of the days I worked and
I am trying to make a program that automatically corrects the perspective of a
I want to make a program that will simulate a user browsing a site
I want to make a program that will read some number in string format
I'm trying to make a program that reads the value at a certain address.
I need to make a program that adds long integers without using the biginteger
A am trying to make a program that takes a signal from one class
I am trying to make a program that will find similar images from a

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.