File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes troubleshooting a button that doesn't work. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "troubleshooting a button that doesn Watch "troubleshooting a button that doesn New topic

troubleshooting a button that doesn't work.

D diller

Joined: Nov 15, 2007
Posts: 29
Finally finishing up that program that I got a bit of help on the other day, and it's coming together quite nicely except for one problem - when I click on my 'Next' button, nothing happens.

I have a 2D array of type Boolean which I randomly disperse 'True' values around in. It works great, and I can create an array of any size pretty much and have any number of elements be true or false. The 'Next' button will eventually be different than this, but it's like it's not executing at all.

That's for the 'Next' button, and my nextGeneration:

I realize that all my 'Next' button should do is just make all the values of my array false, and I have another button that does that and it works - in fact, I just copied and pasted that code. So can anybody give me any pointers/things to look for? I'm dumbfounded.

Side note: What does "String[] args" mean? like if I had 'public void nextGeneration(String[] args){' instead>
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11957

"String[] args" means you are passing in an array of Strings, an will refer to it as 'args' within your method.

You would then refer to args[0], or args[1], or args[479] - with the usual index-out-of bounds caveats.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
D diller

Joined: Nov 15, 2007
Posts: 29
Alright, got the code to run now; still not complete for how it should be, but it'll do.
pete stein

Joined: Feb 23, 2007
Posts: 1561
I'm assuming that you're doing a Conway's Game of Life app. If so, then your next generation algorithm is the heart of your program, is the most important method that your app has. Basically it loops through your 2D array, and based on the current state of the array's cells determines whether each cell will be alive or dead in the coming generation. This formula is simple, is readily available at many sources including Wikipedia, and I'll bet in your notes. I'd give it a go if I were you, and we hope for the best. Come on back if you trip up.
I agree. Here's the link:
subject: troubleshooting a button that doesn't work.
It's not a secret anymore!