I am working on a project and we are learning arrays. I need to create a GUI that has 12 buttons but need to be in an array. I am not finished with my code, so it may have errors because of that.
Where I am getting an error is on my
JButton[] = { new Jbutton("1"), ...};
the 2nd ] has a red line under it and gives me the error
Syntax error on token "]" VariableDeclaratorld expected after this token
Heres my code so far:
public class TextButtonsHW extends JFrame implements ActionListener {
private JButton[] buttons;
private JTextArea textArea;
private final int ENTER;
private final int SPACE;
private final int CLEAR;
public TextButtonsHW(String title) {
super(title);
JButton[] = { new JButton("A"), new JButton("B"), new JButton("C"),
new JButton("1"), new JButton("2"), new JButton("3"),
new JButton("X"), new JButton("Y"), new JButton("Z"),
new JButton("Enter"), new JButton("Space"), new JButton("Clear")};
}
}
JFrame, just use an instance of a frame.