Now I am writing a calculator, here is a small question:
I create buttons from an array of strings (so that they don't take up much space)
String [] buttonName = {"1","2","3","/","4","5","6","*","7","8","9","+","0","-","C","="}; for (String string : buttonName) { panel2.add(new JButton(String.valueOf(string))); }
How, in this case, to add an ActionListener to each button?