|
|
我了一个用array来制造的button,A~Z,我要如何判断是哪个判断那个button被按然后要display在textfield- String [] secretWord = {"S","W","I","N","G"};
- String [] abcd={"A","B","C","D","E","F","G","H","I","J","K","L","N","M","O","P","Q","R"
- +"","S","T","U","V","W","X","Y","Z"};
- JButton [] efgh = new JButton[abcd.length];
- JTextField [] input= new JTextField[secretWord.length];
复制代码- for(int i=0;i<secretWord.length;i++)
- {
- input[i] = new JTextField(6);
- test2.add(input[i]);
- }
- for(int j=0;j<abcd.length;j++)
- {
- efgh[j] = new JButton(abcd[j]);
- efgh[j].addActionListener(this);
- test3.add(efgh[j]);
- }
复制代码 |
-
这个就是我的interface
|