I'm writing my first calculator in Java Swing and I would like, when I press for example "1" of my keyboard, it execute the ActionListener
of my button.
No "ALT-1" or "CTRL-1", just the key "1".
Here is an example of my buttons :
n0.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String nombre0 = Integer.toString(nb0);
textFieldAns.setText(textFieldAns.getText() + nombre0);
}
});
I don't know if you want an another parts of my code