我正在開發一個項目,我們正在學習數組。我需要創建一個有12個按鈕的GUI,但需要在一個數組中。我沒有完成我的代碼,因此可能會有錯誤。陣列中的GUI按鈕
當我得到一個錯誤是我
JButton[] = { new Jbutton("1"), ...};
第2]有下有一個紅色的線和給我的錯誤
Syntax error on token "]" VariableDeclaratorld expected after this token
繼承人到目前爲止我的代碼:
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',只需使用一個框架的實例。 – 2013-04-21 04:57:00