I'm trying to build a panel that has nine buttons. Each button will need to show the value of an item in an array. So I built my array and tried to set the value of Button2 with the following code.
When compiling I get the error:
cannot find symbol
symbol : constructor JButton(int)
location: class javax.swing.JButton
If I substitute
It adds the button with the text Button 2.
Is there a different syntax that I should be using to equate the text of the button to the value of the array?
I haven't started building the Listeners and ActionPerformed yet, do I need that before this will work?
You're trying to call the constructor with an int as parameter. That constructor doesn't exist. You want to call it with a String. So the solution is to create a String from that int.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.