我试图将按钮背景设置为数组中保存的值,但我得到错误?
一、二、三是JButton。(这只是我稍后必须扩展的一些代码)
public void actionPerformed( ActionEvent event ) {
String[] colors = {"GREEN","WHITE","ORANGE"};
if(event.getSource() == one){
String text = "Clicks = " + ++ clicks1 + ". ";
one.setText( text );
one.setBackground(Color.colors[0]);
two.setBackground(Color.colors[1]);
three.setBackground(Color.colors[2]);