I'm trying to make a click game. In the game, player must click at random placed numbers from 1 to 36(table 6x6). If player get wrong game will restart, if it's presed ok number will become X. On 1st click = No1, this click start the timer and when player click No36 stop the timer. This is the 1st frame, on second frame game display the time from 1 to 36 click. I tryed to made this game but I have a problem with aray of numbers. How to define that player must click from 1 to 36 by arow, and if get wrong restart game.
For now I have a frame with 36 buttons, timer, action listener, but I don't have an idea how to solve the problem.
Thanks in advance
you should never write a line of code until you have thoroughly analyzed the problem, understand how to do everything, and thought through the best ways to do it. Writing code before figuring out all that will cause you no end of trouble.
So...forget about java for a while. figure out, in English (or any natural language you prefer) how YOU would do it. better yet, write down the steps as if you were telling a 8-yr old child how to do it. Once you have that done, writing the code usually follows pretty easy. If it doesn't, odds are you haven't refined your steps well enough to really explain what to do.
don't get me wrong...writing code is the best way to learn. Fred Brooks wrote in his book "The Mythical Man-Month" that you should "plan on writing one to throw away".
What he meant was that no matter how much planning you do ahead of time, when you really get down into it, when you actually start writing the code, you'll find all kinds of things you forgot to consider before you began, and will be hard to shoe-horn into what you have written to that point.
So don't delete what you wrote...just move it aside, reference it as you write you new code, and learn from what you've already done.
Please Help. I made some changes in game. Now player have a frame with shuffled 36 numbers. Player must click on all 36 buttons from 1 to 36, and if get wrong buttons shuffled again. If player do as it must after the 36th click joptionpane give a massage of time between 1 and 36 click, that's all. After many corrections I made on game I am again on begining. Here is my code where I was stuck.
I can't get good shuffle collection for buttons with string on it, and than use action listener for string on button, then make array for if else, and that array compare with array of 1-36 and put else with shuffle again.
Can somebody give me a good example I have no time anymore. Must send for a 2 days.
Thanks
Where is "the first line about the shuffle"? the code you posted compiles and runs.
An ArrayOutOfBounds exception is just what you'd think it is, based on its name. Java is telling you that you are trying to access the 37th element (index 36), but your array doesn't have that many elements.
I can't see where that would be happening, based on your code. Further, the error message tells you EXACTLY what line the error is occurring on.
So, without the actual code you are trying to run, and without the FULL error message, there is nothing I can do.
Here is my code, and finally it works. I got random numbers, and action listener can recognize it. Now I need a help about actionlistener. How define the aray from 1-36, and if else restart JFrame? I looked for some sort of button++ solution, but I am green in Java for that. If someone know this kinde of solution I'll appreciate that.
Thanks in advance