have an array of JButtons in a grid
where I need to add the new line of code
Norm Radder wrote:
have an array of JButtons in a grid
Are you asking how to get the row,column location of a button that was clicked on?
One way is to store the button's location inside of the button object so it can be retrieved from the button object when it is passed to a listener.
where I need to add the new line of code
What is that for?
how would I do that?
Ben Grabouski wrote:
Carey Brown wrote:A 2D array doesn't have a position '1', it does have a position (0,0) though.
I know, I need it to convert that position [0][0] to a string saying 1
Ben Grabouski wrote:
Carey Brown wrote:A 2D array doesn't have a position '1', it does have a position (0,0) though.
I know, I need it to convert that position [0][0] to a string saying 1
when the baby stands on it
Carey Brown wrote:This is your first mention of a TextField. Is there an array of TextFields or only one? If the text field displays '27' what does that tell you?
Carey Brown wrote:This is your first mention of a TextField. Is there an array of TextFields or only one? If the text field displays '27' what does that tell you?
Carey Brown wrote:...and what if baby moves down 1?
Ben Grabouski wrote:
Carey Brown wrote:This is your first mention of a TextField. Is there an array of TextFields or only one? If the text field displays '27' what does that tell you?
if the text field said the number 27 the baby is stood in [11][1]
I am afraid that doesn't strike me as a good solution. What you now have is parallel arrays, which are very error‑prone. It would be better to create a Baby class and a Brick class, each of which has fields recording its location. You can have a move(Direction) method, and an enum for directions.You can get the Baby to test the array for whether there is a route where it is trying to go. Or, more object‑orientedly, create a Location object and a Map to link locations with bricks.Ben Grabouski wrote:. . . another 2d array . . . .
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
|